Skip to content

Commit

Permalink
compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumExplorer committed Dec 26, 2024
1 parent 4214369 commit b30ba05
Show file tree
Hide file tree
Showing 42 changed files with 1,543 additions and 331 deletions.
10 changes: 5 additions & 5 deletions packages/dapi-grpc/protos/platform/v0/platform.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ message GetCurrentQuorumsInfoResponse {
message GetIdentityTokenBalancesRequest {
message GetIdentityTokenBalancesRequestV0 {
bytes identity_id = 1; // ID of the identity
repeated bytes contract_ids = 2; // List of token contract IDs
repeated bytes token_ids = 2; // List of token IDs
bool prove = 3; // Flag to request a proof as the response
}
oneof version {
Expand All @@ -1232,8 +1232,8 @@ message GetIdentityTokenBalancesRequest {
message GetIdentityTokenBalancesResponse {
message GetIdentityTokenBalancesResponseV0 {
message TokenBalanceEntry {
bytes contract_id = 1; // Token contract ID
uint64 balance = 2; // Token balance for the contract
bytes token_id = 1; // Token ID
optional uint64 balance = 2; // Token balance for the contract
}

message TokenBalances {
Expand All @@ -1253,7 +1253,7 @@ message GetIdentityTokenBalancesResponse {

message GetIdentitiesTokenBalancesRequest {
message GetIdentitiesTokenBalancesRequestV0 {
bytes contract_id = 1; // Token contract ID
bytes token_id = 1; // Token ID
repeated bytes identity_ids = 2; // List of identity IDs
bool prove = 3; // Flag to request a proof as the response
}
Expand All @@ -1266,7 +1266,7 @@ message GetIdentitiesTokenBalancesResponse {
message GetIdentitiesTokenBalancesResponseV0 {
message IdentityTokenBalanceEntry {
bytes identity_id = 1; // Identity ID
uint64 balance = 2; // Token balance for the identity
optional uint64 balance = 2; // Token balance for the identity
}

message IdentityTokenBalances {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl<'a> ExecutionEvent<'a> {
)))
}
}
StateTransitionAction::DocumentsBatchAction(document_batch_action) => {
StateTransitionAction::BatchAction(document_batch_action) => {
let user_fee_increase = action.user_fee_increase();
let removed_balance = document_batch_action.all_used_balances()?;
let operations =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use dpp::consensus::basic::identity::{
IdentityAssetLockTransactionIsNotFoundError, IdentityAssetLockTransactionOutputNotFoundError,
InvalidAssetLockProofTransactionHeightError,
};
use dpp::dashcore::secp256k1::ThirtyTwoByteHash;
use dpp::dashcore::hashes::Hash;
use dpp::dashcore::TxOut;
use dpp::identity::state_transition::asset_lock_proof::validate_asset_lock_transaction_structure::validate_asset_lock_transaction_structure;
use dpp::prelude::{AssetLockProof, ConsensusValidationResult};
Expand Down Expand Up @@ -49,7 +49,7 @@ pub fn fetch_asset_lock_transaction_output_sync_v0<C: CoreRPCLike>(

let Some(transaction_info) = maybe_transaction_info else {
// Transaction hash bytes needs to be reversed to match actual transaction hash
let mut hash = transaction_hash.as_raw_hash().into_32();
let mut hash: [u8; 32] = transaction_hash.as_raw_hash().to_byte_array();
hash.reverse();

return Ok(ValidationResult::new_with_error(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use dashcore_rpc::dashcore::Network;
use dpp::block::block_info::BlockInfo;
use dpp::identifier::Identifier;
use dpp::validation::SimpleConsensusValidationResult;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
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_identity_already_contestant::DocumentContestIdentityAlreadyContestantError;
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;
use dpp::prelude::{ConsensusValidationResult, Identifier};
use dpp::validation::SimpleConsensusValidationResult;
use drive::state_transition_action::document::documents_batch::document_transition::document_base_transition_action::DocumentBaseTransitionActionAccessorsV0;
Expand All @@ -18,10 +9,7 @@ use drive::error::drive::DriveError;
use drive::query::TransactionArg;
use drive::state_transition_action::document::documents_batch::document_transition::token_base_transition_action::TokenBaseTransitionActionAccessorsV0;
use crate::error::Error;
use crate::execution::types::execution_operation::ValidationOperation;
use crate::execution::types::state_transition_execution_context::{StateTransitionExecutionContext, StateTransitionExecutionContextMethodsV0};
use crate::execution::validation::state_transition::batch::state::v0::fetch_contender::fetch_contender;
use crate::execution::validation::state_transition::batch::state::v0::fetch_documents::fetch_document_with_id;
use crate::execution::types::state_transition_execution_context::StateTransitionExecutionContext;
use crate::platform_types::platform::PlatformStateRef;

pub(super) trait TokenTransferTransitionActionStateValidationV0 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
use dpp::block::block_info::BlockInfo;
use dpp::consensus::basic::document::{DocumentCreationNotAllowedError, InvalidDocumentTypeError};
use dpp::consensus::state::document::document_contest_not_paid_for_error::DocumentContestNotPaidForError;
use dpp::dashcore::Network;
use dpp::data_contract::accessors::v0::DataContractV0Getters;
use dpp::data_contract::accessors::v1::DataContractV1Getters;
use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters;
use dpp::data_contract::document_type::methods::DocumentTypeV0Methods;
use dpp::data_contract::document_type::restricted_creation::CreationRestrictionMode;
use dpp::data_contract::validate_document::DataContractDocumentValidationMethodsV0;
use dpp::identifier::Identifier;
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::token_transfer_transition_action::{TokenTransferTransitionAction, TokenTransferTransitionActionAccessors};
use dpp::version::PlatformVersion;
use drive::state_transition_action::document::documents_batch::document_transition::token_base_transition_action::TokenBaseTransitionActionAccessorsV0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ use dpp::dashcore::Network;
use dpp::document::Document;
use dpp::identity::identity_public_key::accessors::v0::IdentityPublicKeyGettersV0;
use dpp::identity::PartialIdentity;
use dpp::state_transition::batch_transition::batched_transition::document_transition::{
DocumentTransition, DocumentTransitionV0Methods,
};
use dpp::state_transition::batch_transition::batched_transition::document_transition::DocumentTransition;
use dpp::state_transition::batch_transition::document_base_transition::v0::v0_methods::DocumentBaseTransitionV0Methods;
use dpp::state_transition::batch_transition::BatchTransition;
use dpp::state_transition::{StateTransitionIdentitySigned, StateTransitionLike};
Expand All @@ -20,7 +18,7 @@ use dpp::validation::ConsensusValidationResult;
use dpp::version::PlatformVersion;

use drive::state_transition_action::document::documents_batch::document_transition::{BatchedTransitionAction, DocumentTransitionAction, TokenTransitionAction};
use drive::state_transition_action::document::documents_batch::DocumentsBatchTransitionAction;
use drive::state_transition_action::document::documents_batch::BatchTransitionAction;
use crate::execution::validation::state_transition::state_transitions::batch::action_validation::document_replace_transition_action::DocumentReplaceTransitionActionValidation;
use crate::execution::validation::state_transition::state_transitions::batch::action_validation::document_delete_transition_action::DocumentDeleteTransitionActionValidation;
use crate::execution::validation::state_transition::state_transitions::batch::action_validation::document_create_transition_action::DocumentCreateTransitionActionValidation;
Expand Down Expand Up @@ -50,7 +48,7 @@ pub(in crate::execution::validation::state_transition::state_transitions::batch)
&self,
block_info: &BlockInfo,
network: Network,
action: &DocumentsBatchTransitionAction,
action: &BatchTransitionAction,
identity: &PartialIdentity,
execution_context: &mut StateTransitionExecutionContext,
platform_version: &PlatformVersion,
Expand All @@ -62,7 +60,7 @@ impl DocumentsBatchStateTransitionStructureValidationV0 for BatchTransition {
&self,
block_info: &BlockInfo,
network: Network,
action: &DocumentsBatchTransitionAction,
action: &BatchTransitionAction,
identity: &PartialIdentity,
execution_context: &mut StateTransitionExecutionContext,
platform_version: &PlatformVersion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use dpp::version::PlatformVersion;
use crate::execution::validation::state_transition::batch::data_triggers::bindings::data_trigger_binding::DataTriggerBinding;
use crate::execution::validation::state_transition::batch::data_triggers::bindings::data_trigger_binding::DataTriggerBindingV0Getters;
use crate::error::Error;
use crate::error::execution::ExecutionError;

pub trait DataTriggerExecutor {
fn validate_with_data_triggers(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use drive::state_transition_action::document::documents_batch::document_transiti
use crate::error::Error;
use crate::execution::validation::state_transition::batch::data_triggers::DataTriggerExecutionResult;
use drive::state_transition_action::document::documents_batch::document_transition::DocumentTransitionAction;
use crate::error::execution::ExecutionError;

/// Creates a data trigger for handling document rejections.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::error::Error;
use dpp::block::block_info::BlockInfo;
use dpp::identity::identity_nonce::{validate_identity_nonce_update, validate_new_identity_nonce};
use dpp::state_transition::batch_transition::accessors::DocumentsBatchTransitionAccessorsV0;
use dpp::state_transition::batch_transition::batched_transition::document_transition::DocumentTransitionV0Methods;

use dpp::state_transition::batch_transition::BatchTransition;
use dpp::state_transition::StateTransitionLike;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ impl StateTransitionStructureKnownInStateValidationV0 for BatchTransition {
identity.ok_or(Error::Execution(ExecutionError::CorruptedCodeExecution(
"The identity must be known on advanced structure validation",
)))?;
let StateTransitionAction::DocumentsBatchAction(documents_batch_transition_action) =
action
let StateTransitionAction::BatchAction(documents_batch_transition_action) = action
else {
return Err(Error::Execution(ExecutionError::CorruptedCodeExecution(
"action must be a documents batch transition action",
Expand Down Expand Up @@ -214,8 +213,7 @@ impl StateTransitionStateValidationV0 for BatchTransition {
action.ok_or(Error::Execution(ExecutionError::CorruptedCodeExecution(
"documents batch structure validation should have an action",
)))?;
let StateTransitionAction::DocumentsBatchAction(documents_batch_transition_action) =
action
let StateTransitionAction::BatchAction(documents_batch_transition_action) = action
else {
return Err(Error::Execution(ExecutionError::CorruptedCodeExecution(
"action must be a documents batch transition action",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use drive::state_transition_action::StateTransitionAction;
use dpp::version::{DefaultForPlatformVersion, PlatformVersion};
use drive::grovedb::TransactionArg;
use drive::state_transition_action::document::documents_batch::document_transition::{BatchedTransitionAction, DocumentTransitionAction, TokenTransitionAction};
use drive::state_transition_action::document::documents_batch::DocumentsBatchTransitionAction;
use drive::state_transition_action::document::documents_batch::BatchTransitionAction;
use drive::state_transition_action::system::bump_identity_data_contract_nonce_action::BumpIdentityDataContractNonceAction;
use crate::error::Error;
use crate::error::execution::ExecutionError;
Expand Down Expand Up @@ -36,7 +36,7 @@ pub(in crate::execution::validation::state_transition::state_transitions::batch)
{
fn validate_state_v0(
&self,
action: DocumentsBatchTransitionAction,
action: BatchTransitionAction,
platform: &PlatformStateRef,
block_info: &BlockInfo,
execution_context: &mut StateTransitionExecutionContext,
Expand All @@ -56,7 +56,7 @@ pub(in crate::execution::validation::state_transition::state_transitions::batch)
impl DocumentsBatchStateTransitionStateValidationV0 for BatchTransition {
fn validate_state_v0(
&self,
mut state_transition_action: DocumentsBatchTransitionAction,
mut state_transition_action: BatchTransitionAction,
platform: &PlatformStateRef,
block_info: &BlockInfo,
execution_context: &mut StateTransitionExecutionContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use drive::state_transition_action::document::documents_batch::document_transiti
use drive::state_transition_action::document::documents_batch::document_transition::document_delete_transition_action::DocumentDeleteTransitionAction;
use drive::state_transition_action::document::documents_batch::document_transition::document_replace_transition_action::DocumentReplaceTransitionAction;
use drive::state_transition_action::document::documents_batch::document_transition::{BatchedTransitionAction, DocumentTransitionAction, TokenTransitionAction};
use drive::state_transition_action::document::documents_batch::DocumentsBatchTransitionAction;
use drive::state_transition_action::document::documents_batch::BatchTransitionAction;
use drive::state_transition_action::document::documents_batch::v0::DocumentsBatchTransitionActionV0;

use crate::execution::validation::state_transition::batch::state::v0::fetch_documents::fetch_documents_for_transitions_knowing_contract_and_document_type;
Expand Down Expand Up @@ -70,7 +70,7 @@ pub(in crate::execution::validation::state_transition::state_transitions::batch)
full_validation: bool,
transaction: TransactionArg,
execution_context: &mut StateTransitionExecutionContext,
) -> Result<ConsensusValidationResult<DocumentsBatchTransitionAction>, Error>;
) -> Result<ConsensusValidationResult<BatchTransitionAction>, Error>;
}

trait BatchTransitionInternalTransformerV0 {
Expand Down Expand Up @@ -146,7 +146,7 @@ impl BatchTransitionTransformerV0 for BatchTransition {
validate_against_state: bool,
transaction: TransactionArg,
execution_context: &mut StateTransitionExecutionContext,
) -> Result<ConsensusValidationResult<DocumentsBatchTransitionAction>, Error> {
) -> Result<ConsensusValidationResult<BatchTransitionAction>, Error> {
let owner_id = self.owner_id();
let user_fee_increase = self.user_fee_increase();
let platform_version = platform.state.current_platform_version()?;
Expand Down
1 change: 1 addition & 0 deletions packages/rs-drive-abci/src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ mod proofs;
mod response_metadata;
mod service;
mod system;
mod token_queries;
mod validator_queries;
mod voting;

Expand Down
Original file line number Diff line number Diff line change
@@ -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_identities_token_balances_request::Version as RequestVersion;
use dapi_grpc::platform::v0::get_identities_token_balances_response::Version as ResponseVersion;
use dapi_grpc::platform::v0::{
GetIdentitiesTokenBalancesRequest, GetIdentitiesTokenBalancesResponse,
};
use dpp::version::PlatformVersion;
mod v0;

impl<C> Platform<C> {
/// Querying of an identity's token balances by a public key hash
pub fn query_identities_token_balances(
&self,
GetIdentitiesTokenBalancesRequest { version }: GetIdentitiesTokenBalancesRequest,
platform_state: &PlatformState,
platform_version: &PlatformVersion,
) -> Result<QueryValidationResult<GetIdentitiesTokenBalancesResponse>, Error> {
let Some(version) = version else {
return Ok(QueryValidationResult::new_with_error(
QueryError::DecodingError(
"could not decode identity token balances query".to_string(),
),
));
};

let feature_version_bounds = &platform_version
.drive_abci
.query
.token_queries
.identities_token_balances;

let feature_version = match &version {
RequestVersion::V0(_) => 0,
};
if !feature_version_bounds.check_version(feature_version) {
return Ok(QueryValidationResult::new_with_error(
QueryError::UnsupportedQueryVersion(
"identities_token_balances".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_identities_token_balances_v0(
request_v0,
platform_state,
platform_version,
)?;
Ok(
result.map(|response_v0| GetIdentitiesTokenBalancesResponse {
version: Some(ResponseVersion::V0(response_v0)),
}),
)
}
}
}
}
Loading

0 comments on commit b30ba05

Please sign in to comment.