Skip to content

Commit

Permalink
fixes for wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumExplorer committed Jan 6, 2025
1 parent d10ffa2 commit da5d87a
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ impl<'a> Iterator for DocumentBatchIterator<'a> {
}

impl DocumentsBatchTransitionAccessorsV0 for BatchTransition {
type IterType<'a> = DocumentBatchIterator<'a>
type IterType<'a>
= DocumentBatchIterator<'a>
where
Self: 'a;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ use crate::state_transition::batch_transition::resolvers::v0::BatchTransitionRes
use crate::state_transition::state_transitions::document::batch_transition::batched_transition::document_transition::DocumentTransitionV0Methods;

impl DocumentsBatchTransitionAccessorsV0 for BatchTransitionV0 {
type IterType<'a> = std::iter::Map<Iter<'a, DocumentTransition>, fn(&'a DocumentTransition) -> BatchedTransitionRef<'a>>
type IterType<'a>
= std::iter::Map<
Iter<'a, DocumentTransition>,
fn(&'a DocumentTransition) -> BatchedTransitionRef<'a>,
>
where
Self: 'a;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ use crate::state_transition::batch_transition::token_transfer_transition::TokenT
use crate::state_transition::batch_transition::token_unfreeze_transition::TokenUnfreezeTransitionV0;

impl DocumentsBatchTransitionAccessorsV0 for BatchTransitionV1 {
type IterType<'a> = Map<Iter<'a, BatchedTransition>, fn(&'a BatchedTransition) -> BatchedTransitionRef<'a>>
type IterType<'a>
= Map<Iter<'a, BatchedTransition>, fn(&'a BatchedTransition) -> BatchedTransitionRef<'a>>
where
Self: 'a;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ use crate::platform_types::signature_verification_quorum_set::{
Quorums, SignatureVerificationQuorumSetForSaving, SignatureVerificationQuorumSetV0,
ThresholdBlsPublicKey, VerificationQuorum,
};
use bincode::{Decode, Encode};
use dashcore_rpc::dashcore::hashes::Hash;
use dashcore_rpc::dashcore::QuorumHash;
use dpp::bls_signatures::Bls12381G2Impl;
use dpp::identity::state_transition::asset_lock_proof::Encode;
use dpp::platform_serialization::de::Decode;
use dpp::platform_value::Bytes32;

#[derive(Debug, Clone, Encode, Decode)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub const DRIVE_ABCI_VALIDATION_VERSIONS_V5: DriveAbciValidationVersions =
state: 0,
transform_into_action: 0,
},
documents_batch_state_transition: DriveAbciDocumentsStateTransitionValidationVersions {
batch_state_transition: DriveAbciDocumentsStateTransitionValidationVersions {
balance_pre_check: 0,
basic_structure: 0,
advanced_structure: 0,
Expand Down Expand Up @@ -133,6 +133,17 @@ pub const DRIVE_ABCI_VALIDATION_VERSIONS_V5: DriveAbciValidationVersions =
document_transfer_transition_state_validation: 0,
document_purchase_transition_state_validation: 0,
document_update_price_transition_state_validation: 0,
token_mint_transition_structure_validation: 0,
token_burn_transition_structure_validation: 0,
token_transfer_transition_structure_validation: 0,
token_issuance_transition_state_validation: 0,
token_burn_transition_state_validation: 0,
token_transfer_transition_state_validation: 0,
token_base_transition_structure_validation: 0,
token_freeze_transition_structure_validation: 0,
token_unfreeze_transition_structure_validation: 0,
token_freeze_transition_state_validation: 0,
token_unfreeze_transition_state_validation: 0,
},
},
has_nonce_validation: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use dpp::consensus::ConsensusError;
use dpp::platform_value::BinaryData;
use dpp::serialization::PlatformSerializable;
use dpp::state_transition::batch_transition::accessors::DocumentsBatchTransitionAccessorsV0;
use dpp::state_transition::batch_transition::batched_transition::document_transition::DocumentTransition;
use dpp::state_transition::batch_transition::BatchTransition;
use dpp::state_transition::StateTransition;
use wasm_bindgen::prelude::*;
Expand All @@ -26,7 +25,6 @@ use crate::{
IdentityPublicKeyWasm,
};

use document_transition::DocumentTransitionWasm;
use dpp::ed25519_dalek::ed25519::signature::SignerMut;
use dpp::state_transition::batch_transition::batched_transition::BatchedTransition;
use dpp::state_transition::batch_transition::methods::v0::DocumentsBatchTransitionMethodsV0;
Expand Down
54 changes: 51 additions & 3 deletions packages/wasm-dpp/src/errors/consensus/consensus_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ use dpp::consensus::state::data_trigger::DataTriggerError::{
DataTriggerConditionError, DataTriggerExecutionError, DataTriggerInvalidResultError,
};
use wasm_bindgen::{JsError, JsValue};
use dpp::consensus::basic::data_contract::{ContestedUniqueIndexOnMutableDocumentTypeError, ContestedUniqueIndexWithUniqueIndexError, DataContractTokenConfigurationUpdateError, InvalidDocumentTypeRequiredSecurityLevelError, UnknownDocumentCreationRestrictionModeError, UnknownSecurityLevelError, UnknownStorageKeyRequirementsError, UnknownTradeModeError, UnknownTransferableTypeError};
use dpp::consensus::basic::data_contract::{ContestedUniqueIndexOnMutableDocumentTypeError, ContestedUniqueIndexWithUniqueIndexError, DataContractTokenConfigurationUpdateError, InvalidDocumentTypeRequiredSecurityLevelError, InvalidTokenBaseSupplyError, NonContiguousContractGroupPositionsError, NonContiguousContractTokenPositionsError, UnknownDocumentCreationRestrictionModeError, UnknownSecurityLevelError, UnknownStorageKeyRequirementsError, UnknownTradeModeError, UnknownTransferableTypeError};
use dpp::consensus::basic::document::{ContestedDocumentsTemporarilyNotAllowedError, DocumentCreationNotAllowedError, DocumentFieldMaxSizeExceededError, MaxDocumentsTransitionsExceededError, MissingPositionsInDocumentTypePropertiesError};
use dpp::consensus::basic::group::GroupActionNotAllowedOnTransitionError;
use dpp::consensus::basic::identity::{DataContractBoundsNotPresentError, DisablingKeyIdAlsoBeingAddedInSameTransitionError, InvalidIdentityCreditWithdrawalTransitionAmountError, InvalidIdentityUpdateTransitionDisableKeysError, InvalidIdentityUpdateTransitionEmptyError, TooManyMasterPublicKeyError, WithdrawalOutputScriptNotAllowedWhenSigningWithOwnerKeyError};
use dpp::consensus::basic::overflow_error::OverflowError;
use dpp::consensus::basic::token::{InvalidActionIdError, InvalidGroupPositionError, InvalidTokenIdError, InvalidTokenPositionError};
use dpp::consensus::basic::token::contract_has_no_tokens_error::ContractHasNoTokensError;
use dpp::consensus::basic::token::{ChoosingTokenMintRecipientNotAllowedError, ContractHasNoTokensError, DestinationIdentityForTokenMintingNotSetError, InvalidActionIdError, InvalidGroupPositionError, InvalidTokenIdError, InvalidTokenPositionError, TokenTransferToOurselfError};
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_document_with_same_id_already_present_error::DocumentContestDocumentWithSameIdAlreadyPresentError;
Expand All @@ -75,12 +75,15 @@ use dpp::consensus::state::document::document_contest_not_joinable_error::Docume
use dpp::consensus::state::document::document_contest_not_paid_for_error::DocumentContestNotPaidForError;
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::group::{GroupActionAlreadyCompletedError, GroupActionAlreadySignedByIdentityError, GroupActionDoesNotExistError, IdentityNotMemberOfGroupError};
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::identity::missing_transfer_key_error::MissingTransferKeyError;
use dpp::consensus::state::identity::no_transfer_key_for_core_withdrawal_available_error::NoTransferKeyForCoreWithdrawalAvailableError;
use dpp::consensus::state::identity::RecipientIdentityDoesNotExistError;
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::token::{IdentityDoesNotHaveEnoughTokenBalanceError, IdentityTokenAccountFrozenError, UnauthorizedTokenActionError};
use dpp::consensus::state::voting::masternode_incorrect_voter_identity_id_error::MasternodeIncorrectVoterIdentityIdError;
use dpp::consensus::state::voting::masternode_incorrect_voting_address_error::MasternodeIncorrectVotingAddressError;
use dpp::consensus::state::voting::masternode_not_found_error::MasternodeNotFoundError;
Expand Down Expand Up @@ -310,6 +313,30 @@ pub fn from_state_error(state_error: &StateError) -> JsValue {
StateError::DocumentContestNotPaidForError(e) => {
generic_consensus_error!(DocumentContestNotPaidForError, e).into()
}
StateError::RecipientIdentityDoesNotExistError(e) => {
generic_consensus_error!(RecipientIdentityDoesNotExistError, e).into()
}
StateError::IdentityDoesNotHaveEnoughTokenBalanceError(e) => {
generic_consensus_error!(IdentityDoesNotHaveEnoughTokenBalanceError, e).into()
}
StateError::UnauthorizedTokenActionError(e) => {
generic_consensus_error!(UnauthorizedTokenActionError, e).into()
}
StateError::IdentityTokenAccountFrozenError(e) => {
generic_consensus_error!(IdentityTokenAccountFrozenError, e).into()
}
StateError::IdentityNotMemberOfGroupError(e) => {
generic_consensus_error!(IdentityNotMemberOfGroupError, e).into()
}
StateError::GroupActionDoesNotExistError(e) => {
generic_consensus_error!(GroupActionDoesNotExistError, e).into()
}
StateError::GroupActionAlreadyCompletedError(e) => {
generic_consensus_error!(GroupActionAlreadyCompletedError, e).into()
}
StateError::GroupActionAlreadySignedByIdentityError(e) => {
generic_consensus_error!(GroupActionAlreadySignedByIdentityError, e).into()
}
}
}

Expand Down Expand Up @@ -595,6 +622,27 @@ fn from_basic_error(basic_error: &BasicError) -> JsValue {
BasicError::InvalidActionIdError(e) => {
generic_consensus_error!(InvalidActionIdError, e).into()
}
BasicError::NonContiguousContractTokenPositionsError(e) => {
generic_consensus_error!(NonContiguousContractTokenPositionsError, e).into()
}
BasicError::NonContiguousContractGroupPositionsError(e) => {
generic_consensus_error!(NonContiguousContractGroupPositionsError, e).into()
}
BasicError::InvalidTokenBaseSupplyError(e) => {
generic_consensus_error!(InvalidTokenBaseSupplyError, e).into()
}
BasicError::TokenTransferToOurselfError(e) => {
generic_consensus_error!(TokenTransferToOurselfError, e).into()
}
BasicError::DestinationIdentityForTokenMintingNotSetError(e) => {
generic_consensus_error!(DestinationIdentityForTokenMintingNotSetError, e).into()
}
BasicError::ChoosingTokenMintRecipientNotAllowedError(e) => {
generic_consensus_error!(ChoosingTokenMintRecipientNotAllowedError, e).into()
}
BasicError::GroupActionNotAllowedOnTransitionError(e) => {
generic_consensus_error!(GroupActionNotAllowedOnTransitionError, e).into()
}
}
}

Expand Down

0 comments on commit da5d87a

Please sign in to comment.