From da5d87ad4d2b8b6f2e5788de5ded7c47ad0d3fcf Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 6 Jan 2025 16:32:38 +0700 Subject: [PATCH] fixes for wasm --- .../batch_transition/accessors/mod.rs | 3 +- .../batch_transition/v0/v0_methods.rs | 6 ++- .../batch_transition/v1/v0_methods.rs | 3 +- .../v0/for_saving_v1.rs | 3 +- .../drive_abci_validation_versions/v5.rs | 13 ++++- .../state_transition/batch_transition/mod.rs | 2 - .../src/errors/consensus/consensus_error.rs | 54 +++++++++++++++++-- 7 files changed, 73 insertions(+), 11 deletions(-) diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/accessors/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/accessors/mod.rs index 559708b873..fe3a6bef7e 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/accessors/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/accessors/mod.rs @@ -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; diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/v0/v0_methods.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/v0/v0_methods.rs index aeb895201e..17b7c8df12 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/v0/v0_methods.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/v0/v0_methods.rs @@ -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, fn(&'a DocumentTransition) -> BatchedTransitionRef<'a>> + type IterType<'a> + = std::iter::Map< + Iter<'a, DocumentTransition>, + fn(&'a DocumentTransition) -> BatchedTransitionRef<'a>, + > where Self: 'a; diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/v1/v0_methods.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/v1/v0_methods.rs index 1d2abd28c3..22622fd189 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/v1/v0_methods.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/v1/v0_methods.rs @@ -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, fn(&'a BatchedTransition) -> BatchedTransitionRef<'a>> + type IterType<'a> + = Map, fn(&'a BatchedTransition) -> BatchedTransitionRef<'a>> where Self: 'a; diff --git a/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v1.rs b/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v1.rs index bfb596e451..b06d75eacc 100644 --- a/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v1.rs +++ b/packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving_v1.rs @@ -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)] diff --git a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v5.rs b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v5.rs index d48857faba..896e442aa7 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v5.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v5.rs @@ -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, @@ -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, diff --git a/packages/wasm-dpp/src/document/state_transition/batch_transition/mod.rs b/packages/wasm-dpp/src/document/state_transition/batch_transition/mod.rs index 30396e17fc..6dfadbf985 100644 --- a/packages/wasm-dpp/src/document/state_transition/batch_transition/mod.rs +++ b/packages/wasm-dpp/src/document/state_transition/batch_transition/mod.rs @@ -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::*; @@ -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; diff --git a/packages/wasm-dpp/src/errors/consensus/consensus_error.rs b/packages/wasm-dpp/src/errors/consensus/consensus_error.rs index 392b15ebb0..2301255352 100644 --- a/packages/wasm-dpp/src/errors/consensus/consensus_error.rs +++ b/packages/wasm-dpp/src/errors/consensus/consensus_error.rs @@ -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; @@ -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; @@ -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() + } } } @@ -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() + } } }