Skip to content

Commit

Permalink
fix: build broken after merge of contested unique indexes validation (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek authored Jun 17, 2024
1 parent 6ce465d commit 42d8573
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 8 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions packages/rs-dapi-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
default = ["mocks", "offline-testing"]
mocks = ["dep:sha2", "dep:hex", "dapi-grpc/mocks"]
# dump requests and responses to file
dump = ["mocks", "dep:chrono"]
dump = ["mocks"]
# skip tests that require connection to the platform; enabled by default
offline-testing = []

Expand All @@ -22,7 +22,6 @@ thiserror = "1.0.58"
tracing = "0.1.40"
tokio = { version = "1.32.0", default-features = false }
sha2 = { version = "0.10", optional = true }
chrono = { version = "0.4.31", optional = true }
hex = { version = "0.4.3", optional = true }
lru = { version = "0.12.3" }

Expand Down
1 change: 1 addition & 0 deletions packages/rs-dpp/src/errors/consensus/codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ impl ErrorWithCode for BasicError {

// General Errors 10700-10799
Self::OverflowError(_) => 10700,
Self::ContestedUniqueIndexOnMutableDocumentTypeError(_) => 10701,
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion packages/rs-platform-version/src/version/mocks/v2_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,11 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion {
validate_not_defined_properties: 0,
validate_property_definition: 0,
},
document_type: DocumentTypeValidationVersions { validate_update: 0 },
document_type: DocumentTypeValidationVersions {
validate_update: 0,
contested_index_limit: 1,
unique_index_limit: 10,
},
voting: VotingValidationVersions {
allow_other_contenders_time_ms: 604_800_000, // 1 week in ms
votes_allowed_per_masternode: 5,
Expand Down
6 changes: 5 additions & 1 deletion packages/rs-platform-version/src/version/mocks/v3_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,11 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion {
validate_not_defined_properties: 0,
validate_property_definition: 0,
},
document_type: DocumentTypeValidationVersions { validate_update: 0 },
document_type: DocumentTypeValidationVersions {
validate_update: 0,
contested_index_limit: 1,
unique_index_limit: 10,
},
voting: VotingValidationVersions {
allow_other_contenders_time_ms: 604_800_000, // 1 week in ms
votes_allowed_per_masternode: 5,
Expand Down
6 changes: 5 additions & 1 deletion packages/rs-platform-version/src/version/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,11 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion {
validate_not_defined_properties: 0,
validate_property_definition: 0,
},
document_type: DocumentTypeValidationVersions { validate_update: 0 },
document_type: DocumentTypeValidationVersions {
validate_update: 0,
contested_index_limit: 1,
unique_index_limit: 10,
},
voting: VotingValidationVersions {
allow_other_contenders_time_ms: 604_800_000, // 1 week in ms
votes_allowed_per_masternode: 5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl UniqueIndicesLimitReachedErrorWasm {
}

#[wasm_bindgen(js_name=getIndexLimit)]
pub fn get_index_limit(&self) -> usize {
pub fn get_index_limit(&self) -> u16 {
self.inner.index_limit()
}

Expand Down
8 changes: 7 additions & 1 deletion packages/wasm-dpp/src/errors/consensus/consensus_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ use dpp::consensus::state::data_trigger::DataTriggerError::{
DataTriggerConditionError, DataTriggerExecutionError, DataTriggerInvalidResultError,
};
use wasm_bindgen::{JsError, JsValue};
use dpp::consensus::basic::data_contract::{InvalidDocumentTypeRequiredSecurityLevelError, UnknownDocumentCreationRestrictionModeError, UnknownSecurityLevelError, UnknownStorageKeyRequirementsError, UnknownTradeModeError, UnknownTransferableTypeError};
use dpp::consensus::basic::data_contract::{ContestedUniqueIndexOnMutableDocumentTypeError, 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;
Expand Down Expand Up @@ -159,6 +159,9 @@ pub fn from_consensus_error_ref(e: &DPPConsensusError) -> JsValue {
DPPConsensusError::StateError(state_error) => from_state_error(state_error),
DPPConsensusError::BasicError(basic_error) => from_basic_error(basic_error),
DPPConsensusError::DefaultError => JsError::new("DefaultError").into(),
#[cfg(test)]
#[allow(unreachable_patterns)]
e => JsError::new(&format!("unsupported error: {:?}", e)).into(),
}
}

Expand Down Expand Up @@ -518,6 +521,9 @@ fn from_basic_error(basic_error: &BasicError) -> JsValue {
generic_consensus_error!(DocumentCreationNotAllowedError, e).into()
}
BasicError::OverflowError(e) => generic_consensus_error!(OverflowError, e).into(),
BasicError::ContestedUniqueIndexOnMutableDocumentTypeError(e) => {
generic_consensus_error!(ContestedUniqueIndexOnMutableDocumentTypeError, e).into()
}
}
}

Expand Down

0 comments on commit 42d8573

Please sign in to comment.