Skip to content

Commit

Permalink
Merge pull request #38 from dashpay/feature-dpp-0.24.x
Browse files Browse the repository at this point in the history
feat: support 0.24.x
  • Loading branch information
HashEngineering authored Jun 8, 2023
2 parents 5ca581f + 948e127 commit ef2ec2d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 98 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
ext.kotlin_version = '1.4.32'
ext.dashj_version = '19.0-SNAPSHOT'
ext.dashj_version = '19.1-CJ-SNAPSHOT'
ext.dpp_version = '0.24-SNAPSHOT'
repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,6 @@ package org.dashj.platform.dpp.errors.concensus

import org.dashj.platform.dpp.errors.ConcensusErrorMetadata
import org.dashj.platform.dpp.errors.DPPException
import org.dashj.platform.dpp.errors.concensus.basic.IncompatibleProtocolVersionException
import org.dashj.platform.dpp.errors.concensus.basic.JsonSchemaException
import org.dashj.platform.dpp.errors.concensus.basic.UnsupportedProtocolVersionException
import org.dashj.platform.dpp.errors.concensus.basic.datacontract.InvalidDataContractIdException
import org.dashj.platform.dpp.errors.concensus.basic.document.MissingDataContractIdException
import org.dashj.platform.dpp.errors.concensus.basic.identity.IdentityAssetLockTransactionOutPointAlreadyExistsException
import org.dashj.platform.dpp.errors.concensus.basic.identity.InvalidIdentityKeySignatureException
import org.dashj.platform.dpp.errors.concensus.basic.identity.InvalidInstantAssetLockProofException
import org.dashj.platform.dpp.errors.concensus.basic.identity.InvalidInstantAssetLockProofSignatureException
import org.dashj.platform.dpp.errors.concensus.basic.statetransition.InvalidStateTransitionTypeException
import org.dashj.platform.dpp.errors.concensus.basic.statetransition.MissingStateTransitionTypeException
import org.dashj.platform.dpp.errors.concensus.document.DataContractNotPresentException
import org.dashj.platform.dpp.errors.concensus.fee.BalanceIsNotEnoughException
import org.dashj.platform.dpp.errors.concensus.signature.IdentityNotFoundException
import org.dashj.platform.dpp.errors.concensus.signature.InvalidIdentityPublicKeyTypeException
import org.dashj.platform.dpp.errors.concensus.signature.InvalidSignaturePublicKeySecurityLevelException
import org.dashj.platform.dpp.errors.concensus.signature.InvalidStateTransitionSignatureException
import org.dashj.platform.dpp.errors.concensus.signature.MissingPublicKeyException
import org.dashj.platform.dpp.errors.concensus.signature.PublicKeyIsDisabledException
import org.dashj.platform.dpp.errors.concensus.state.document.DocumentAlreadyPresentException
import org.dashj.platform.dpp.errors.concensus.state.document.InvalidDocumentRevisionException
import org.dashj.platform.dpp.errors.concensus.state.identity.DuplicatedIdentityPublicKeyException
import org.dashj.platform.dpp.errors.concensus.state.identity.IdentityAlreadyExistsException
import org.dashj.platform.dpp.toBase64
import org.dashj.platform.dpp.util.Cbor

Expand Down Expand Up @@ -76,79 +53,7 @@ abstract class ConcensusException(message: String) : DPPException(message) {
}

private fun createException(code: Codes, arguments: List<Any>): ConcensusException {
return when (code) {
// remove unneeded errors
// Codes.ProtocolVersionParsingError -> ProtocolVersionParsingException(arguments)
// Codes.SerializedObjectParsingError -> SerializedObjectParsingException(arguments)
Codes.UnsupportedProtocolVersionError -> UnsupportedProtocolVersionException(arguments)
Codes.IncompatibleProtocolVersionError -> IncompatibleProtocolVersionException(arguments)
// Codes.JsonSchemaCompilationError -> JsonSchemaCompilationException(arguments)
Codes.JsonSchemaError -> JsonSchemaException(arguments)
// Codes.InvalidIdentifierError -> InvalidIdentifierException(arguments)
//
// Codes.DataContractMaxDepthExceedError -> DataContractMaxDepthExceedException(arguments)
// Codes.DuplicateIndexError -> DuplicateIndexException(arguments)
// Codes.IncompatibleRe2PatternError -> IncompatibleRe2PatternException(arguments)
// Codes.InvalidCompoundIndexError -> InvalidCompoundIndexException(arguments)
Codes.InvalidDataContractIdError -> InvalidDataContractIdException(arguments)
// Codes.InvalidIndexedPropertyConstraintError -> InvalidIndexedPropertyConstraintException(arguments)
// Codes.InvalidIndexPropertyTypeError -> InvalidIndexPropertyTypeException(arguments)
// Codes.InvalidJsonSchemaRefError -> InvalidJsonSchemaRefException(arguments)
// Codes.SystemPropertyIndexAlreadyPresentError -> SystemPropertyIndexAlreadyPresentException(arguments)
// Codes.UndefinedIndexPropertyError -> UndefinedIndexPropertyException(arguments)
// Codes.UniqueIndicesLimitReachedError -> UniqueIndicesLimitReachedException(arguments)
Codes.DataContractNotPresentError -> DataContractNotPresentException(arguments)
// Codes.DuplicateDocumentTransitionsWithIdsError -> DuplicateDocumentTransitionsWithIdsException(arguments)
// Codes.DuplicateDocumentTransitionsWithIndicesError -> DuplicateDocumentTransitionsWithIndicesException(arguments)
// Codes.InconsistentCompoundIndexDataError -> InconsistentCompoundIndexDataException(arguments)
// Codes.InvalidDocumentTransitionActionError -> InvalidDocumentTransitionActionException(arguments)
// Codes.InvalidDocumentTransitionIdError -> InvalidDocumentTransitionIdException(arguments)
// Codes.InvalidDocumentTypeError -> InvalidDocumentTypeException(arguments)
Codes.MissingDataContractIdError -> MissingDataContractIdException(arguments)
// Codes.MissingDocumentTransitionActionError -> MissingDocumentTransitionActionException(arguments)
// Codes.MissingDocumentTransitionTypeError -> MissingDocumentTransitionTypeException(arguments)
// Codes.MissingDocumentTypeError -> MissingDocumentTypeException(arguments)
Codes.DuplicatedIdentityPublicKeyError -> DuplicatedIdentityPublicKeyException(arguments)
// Codes.DuplicatedIdentityPublicKeyIdError -> DuplicatedIdentityPublicKeyIdException(arguments)
// Codes.IdentityAssetLockProofLockedTransactionMismatchError -> IdentityAssetLockProofLockedTransactionMismatchException(arguments)
// Codes.IdentityAssetLockTransactionIsNotFoundError -> IdentityAssetLockTransactionIsNotFoundException(arguments)
Codes.IdentityAssetLockTransactionOutPointAlreadyExistsError ->
IdentityAssetLockTransactionOutPointAlreadyExistsException(arguments)
// Codes.IdentityAssetLockTransactionOutputNotFoundError -> IdentityAssetLockTransactionOutputNotFoundException(arguments)
// Codes.InvalidAssetLockProofCoreChainHeightError -> InvalidAssetLockProofCoreChainHeightException(arguments)
// Codes.InvalidAssetLockProofTransactionHeightError -> InvalidAssetLockProofTransactionHeightException(arguments)
Codes.InvalidIdentityKeySignatureError -> InvalidIdentityKeySignatureException(arguments)
// Codes.InvalidIdentityAssetLockTransactionError -> InvalidIdentityAssetLockTransactionException(arguments)
// Codes.InvalidIdentityAssetLockTransactionOutputError -> InvalidIdentityAssetLockTransactionOutputException(arguments)
// Codes.InvalidIdentityPublicKeyDataError -> InvalidIdentityPublicKeyDataException(arguments)
Codes.InvalidInstantAssetLockProofError -> InvalidInstantAssetLockProofException(arguments)
Codes.InvalidInstantAssetLockProofSignatureError ->
InvalidInstantAssetLockProofSignatureException(arguments)
Codes.InvalidStateTransitionTypeError -> InvalidStateTransitionTypeException(arguments)
Codes.MissingStateTransitionTypeError -> MissingStateTransitionTypeException()
// Codes.StateTransitionMaxSizeExceededError -> StateTransitionMaxSizeExceededException(arguments)
Codes.IdentityNotFoundError -> IdentityNotFoundException(arguments)
Codes.InvalidIdentityPublicKeyTypeError -> InvalidIdentityPublicKeyTypeException(arguments)
Codes.InvalidStateTransitionSignatureError -> InvalidStateTransitionSignatureException()
Codes.MissingPublicKeyError -> MissingPublicKeyException(arguments)
Codes.PublicKeyIsDisabledError -> PublicKeyIsDisabledException(arguments)
Codes.InvalidSignaturePublicKeySecurityLevelError ->
InvalidSignaturePublicKeySecurityLevelException(arguments)
Codes.BalanceIsNotEnoughError -> BalanceIsNotEnoughException(arguments)
// Codes.DataContractAlreadyPresentError -> DataContractAlreadyPresentException(arguments)
// Codes.DataTriggerConditionError -> DataTriggerConditionException(arguments)
// Codes.DataTriggerExecutionError -> DataTriggerExecutionException(arguments)
// Codes.DataTriggerInvalidResultError -> DataTriggerInvalidResultException(arguments)
Codes.DocumentAlreadyPresentError -> DocumentAlreadyPresentException(arguments)
// Codes.DocumentNotFoundError -> DocumentNotFoundException(arguments)
// Codes.DocumentOwnerIdMismatchError -> DocumentOwnerIdMismatchException(arguments)
// Codes.DocumentTimestampsMismatchError -> DocumentTimestampsMismatchException(arguments)
// Codes.DocumentTimestampWindowViolationError -> DocumentTimestampWindowViolationException(arguments)
// Codes.DuplicateUniqueIndexError -> DuplicateUniqueIndexException(arguments)
Codes.InvalidDocumentRevisionError -> InvalidDocumentRevisionException(arguments)
Codes.IdentityAlreadyExistsError -> IdentityAlreadyExistsException(arguments)
else -> UnknownConcensusError(code.code, arguments)
}
return object : ConcensusException("error $code, $arguments") {}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,13 @@ class IdentityPublicKey(
is Boolean -> rawIdentityPublicKey["readOnly"] as Boolean
else -> false
}
)
) {
when (rawIdentityPublicKey["signature"]) {
is String -> signature = Converters.fromBase64(rawIdentityPublicKey["signature"] as String)
is ByteArray -> signature = rawIdentityPublicKey["signature"] as ByteArray
else -> {}
}
}

override fun toObject(): Map<String, Any> {
return toObject(false)
Expand Down
2 changes: 2 additions & 0 deletions src/test/kotlin/org/dashj/platform/dpp/errors/ErrorsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import org.dashj.platform.dpp.errors.concensus.ConcensusException
import org.dashj.platform.dpp.errors.concensus.basic.identity.InvalidInstantAssetLockProofException
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test

@Disabled
class ErrorsTest {
@Test
fun unauthenticatedTest() {
Expand Down

0 comments on commit ef2ec2d

Please sign in to comment.