@dashevo/wasm-dpp 4.2.0-beta.3 → 4.2.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dashevo/wasm-dpp",
3
- "version": "4.2.0-beta.3",
3
+ "version": "4.2.0-beta.5",
4
4
  "description": "The JavaScript implementation of the Dash Platform Protocol",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -44,7 +44,7 @@
44
44
  "@babel/core": "^7.26.10",
45
45
  "@babel/preset-env": "^7.26.9",
46
46
  "@dashevo/dashcore-lib": "~0.22.0",
47
- "@dashevo/dpns-contract": "4.2.0-beta.3",
47
+ "@dashevo/dpns-contract": "4.2.0-beta.5",
48
48
  "@types/bs58": "^4.0.1",
49
49
  "@types/node": "^20.10.0",
50
50
  "@yarnpkg/pnpify": "^4.0.0-rc.42",
@@ -67,7 +67,7 @@ use dpp::consensus::state::data_trigger::DataTriggerError::{
67
67
  };
68
68
  use wasm_bindgen::{JsError, JsValue};
69
69
  use dpp::consensus::basic::data_contract::{ContestedUniqueIndexOnMutableDocumentTypeError, DataContractInvalidRequiredFieldsUpdateError, ContestedUniqueIndexWithUniqueIndexError, DataContractTokenConfigurationUpdateError, DecimalsOverLimitError, DuplicateKeywordsError, GroupExceedsMaxMembersError, GroupHasTooFewMembersError, GroupMemberHasPowerOfZeroError, GroupMemberHasPowerOverLimitError, GroupNonUnilateralMemberPowerHasLessThanRequiredPowerError, GroupPositionDoesNotExistError, GroupRequiredPowerIsInvalidError, GroupTotalPowerLessThanRequiredError, InvalidDescriptionLengthError, InvalidDocumentTypeRequiredSecurityLevelError, InvalidKeywordCharacterError, InvalidKeywordLengthError, InvalidTokenBaseSupplyError, InvalidTokenDistributionFunctionDivideByZeroError, InvalidTokenDistributionFunctionIncoherenceError, InvalidTokenDistributionFunctionInvalidParameterError, InvalidTokenDistributionFunctionInvalidParameterTupleError, InvalidTokenLanguageCodeError, InvalidTokenNameCharacterError, InvalidTokenNameLengthError, MainGroupIsNotDefinedError, NewTokensDestinationIdentityOptionRequiredError, NonContiguousContractGroupPositionsError, NonContiguousContractTokenPositionsError, PreProgrammedDistributionAmountOverLimitError, RedundantDocumentPaidForByTokenWithContractId, TokenPaymentByBurningOnlyAllowedOnInternalTokenError, TooManyKeywordsError, UnknownDocumentActionTokenEffectError, UnknownDocumentCreationRestrictionModeError, UnknownGasFeesPaidByError, UnknownSecurityLevelError, UnknownStorageKeyRequirementsError, UnknownTradeModeError, UnknownTransferableTypeError};
70
- use dpp::consensus::basic::document::{ContestedDocumentsTemporarilyNotAllowedError, DocumentCreationNotAllowedError, DocumentFieldMaxSizeExceededError, MaxDocumentsTransitionsExceededError, MissingPositionsInDocumentTypePropertiesError};
70
+ use dpp::consensus::basic::document::{ContestedDocumentsTemporarilyNotAllowedError, DocumentCreationNotAllowedError, DocumentFieldMaxSizeExceededError, DocumentPropertyConstraintViolatedError, DocumentPropertyMaxBytesExceededError, DocumentPropertyNotDistinctError, InvalidEncryptedPropertyShapeError, MaxDocumentsTransitionsExceededError, MissingPositionsInDocumentTypePropertiesError};
71
71
  use dpp::consensus::basic::group::GroupActionNotAllowedOnTransitionError;
72
72
  use dpp::consensus::basic::identity::{DataContractBoundsNotPresentError, DisablingKeyIdAlsoBeingAddedInSameTransitionError, InvalidIdentityCreditWithdrawalTransitionAmountError, InvalidIdentityUpdateTransitionDisableKeysError, InvalidIdentityUpdateTransitionEmptyError, InvalidKeyPurposeForContractBoundsError, TooManyMasterPublicKeyError, WithdrawalOutputScriptNotAllowedWhenSigningWithOwnerKeyError};
73
73
  use dpp::consensus::basic::overflow_error::OverflowError;
@@ -78,6 +78,7 @@ use dpp::consensus::state::data_contract::document_type_update_error::DocumentTy
78
78
  use dpp::consensus::state::document::document_contest_currently_locked_error::DocumentContestCurrentlyLockedError;
79
79
  use dpp::consensus::state::document::document_contest_document_with_same_id_already_present_error::DocumentContestDocumentWithSameIdAlreadyPresentError;
80
80
  use dpp::consensus::state::document::document_contest_identity_already_contestant::DocumentContestIdentityAlreadyContestantError;
81
+ use dpp::consensus::state::document::document_contest_maximum_contenders_reached_error::DocumentContestMaximumContendersReachedError;
81
82
  use dpp::consensus::state::document::document_contest_index_mismatch_error::DocumentContestIndexMismatchError;
82
83
  use dpp::consensus::state::document::document_contest_not_joinable_error::DocumentContestNotJoinableError;
83
84
  use dpp::consensus::state::document::document_contest_not_paid_for_error::DocumentContestNotPaidForError;
@@ -91,21 +92,28 @@ use dpp::consensus::basic::contract_group::{
91
92
  InvalidContractGroupAdminsError, RedundantContractGroupMembershipError,
92
93
  };
93
94
  use dpp::consensus::basic::contract_moderation::{
94
- ContractModerationReasonTooLongError, ContractModerationSelfTargetError,
95
+ ContractModerationReasonTooLongError, InvalidContractModerationReasonDocumentsError, ContractModerationSelfTargetError,
95
96
  DocumentActionFeesWithoutModerationError,
96
97
  InvalidContractModerationConfigError,
97
98
  };
99
+ use dpp::consensus::basic::moderation_charter::{
100
+ ModerationCharterMalformedFieldError, ModerationCharterRewardSplitNotOneHundredError,
101
+ };
98
102
  use dpp::consensus::state::contract_moderation::{
99
103
  ContractFeeClaimNotAllowedError, ContractFeesAlreadyClaimedThisEpochError,
100
- ContractFeesNothingToClaimError,
104
+ ContractFeesNothingToClaimError, ContractModeratedDocumentTypeNotYetUsableError,
105
+ ContractModerationAbilityNotGrantedError, ModerationCharterAddedModeratorLimitReachedError,
106
+ ModerationReasonNotListedError,
101
107
  ContractModerationNotEnabledError, ContractModerationTargetNotAllowedError,
102
108
  ContractModerationCounterpartyBarredError, ContractModerationTargetNotFoundError,
103
109
  ContractModeratorIdentityNotFoundError,
104
110
  ContractSuspensionNotInFutureError,
105
111
  ContractUserAlreadyBannedError, ContractUserBannedError, ContractUserNotBannedError,
106
- ContractUserNotSuspendedError, ContractUserSuspendedError,
107
- DocumentModerationWindowElapsedError, DocumentTypeNotDeletableByModeratorsError,
108
- IdentityNotContractModeratorError,
112
+ ContractUserNotSuspendedError, ContractUserNotWarnedError, ContractUserSuspendedError,
113
+ ContractUserWarningLimitReachedError, ContractDocumentAlreadyRestoredError,
114
+ ContractDocumentRemovalNotFoundError, DocumentModerationWindowElapsedError,
115
+ DocumentRestoreHashMismatchError, DocumentRestoreWindowElapsedError,
116
+ DocumentTypeNotDeletableByModeratorsError, IdentityNotContractModeratorError,
109
117
  };
110
118
  use dpp::consensus::state::contract_group::{
111
119
  ContractGroupAdminNotFoundError, ContractGroupAlreadyExistsError, ContractGroupNotFoundError,
@@ -146,6 +154,8 @@ use dpp::consensus::state::document::document_immutable_property_changed_error::
146
154
  use dpp::consensus::state::identity::gas_sponsor_insufficient_balance_error::GasSponsorInsufficientBalanceError;
147
155
  use dpp::consensus::state::token::{GasFeesPaidByNotAllowedError, InconsistentGasFeesPaidByInBatchError};
148
156
  use dpp::consensus::state::document::document_action_fee_agreement_mismatch_error::DocumentActionFeeAgreementMismatchError;
157
+ use dpp::consensus::state::document::document_action_fee_moderators_share_mismatch_error::DocumentActionFeeModeratorsShareMismatchError;
158
+ use dpp::consensus::state::document::document_expired_error::DocumentExpiredError;
149
159
  use dpp::consensus::state::document::document_action_fee_agreement_not_set_error::DocumentActionFeeAgreementNotSetError;
150
160
  use dpp::consensus::state::document::document_action_fee_multiplier_not_tolerated_error::DocumentActionFeeMultiplierNotToleratedError;
151
161
  use dpp::consensus::state::document::referenced_key_id_property_invalid_error::ReferencedKeyIdPropertyInvalidError;
@@ -156,12 +166,17 @@ use dpp::consensus::state::shielded::invalid_anchor_error::InvalidAnchorError;
156
166
  use dpp::consensus::state::shielded::invalid_shielded_proof_error::InvalidShieldedProofError;
157
167
  use dpp::consensus::state::shielded::nullifier_already_spent_error::NullifierAlreadySpentError;
158
168
  use dpp::consensus::basic::state_transition::{StateTransitionNotActiveError, TransitionOverMaxInputsError, TransitionOverMaxOutputsError, InputWitnessCountMismatchError, TransitionNoInputsError, TransitionNoOutputsError, FeeStrategyEmptyError, FeeStrategyDuplicateError, FeeStrategyIndexOutOfBoundsError, FeeStrategyTooManyStepsError, InputBelowMinimumError, OutputBelowMinimumError, InputOutputBalanceMismatchError, OutputsNotGreaterThanInputsError, WithdrawalBalanceMismatchError, InsufficientFundingAmountError, InputsNotLessThanOutputsError, OutputAddressAlsoInputError, InvalidRemainderOutputCountError, WithdrawalBelowMinAmountError, ShieldedNoActionsError, ShieldedTooManyActionsError, ShieldedEmptyProofError, ShieldedZeroAnchorError, ShieldedInvalidValueBalanceError, ShieldedEncryptedNoteSizeMismatchError, ShieldedImplicitFeeCapExceededError, ShieldedInvalidDenominationError};
169
+ use dpp::consensus::state::document::referenced_contract_requirement_not_met_error::ReferencedContractRequirementNotMetError;
170
+ use dpp::consensus::state::document::referenced_identity_key_requirement_not_met_error::ReferencedIdentityKeyRequirementNotMetError;
171
+ use dpp::consensus::state::document::referenced_document_lookup_invalid_error::ReferencedDocumentLookupInvalidError;
172
+ use dpp::consensus::state::document::referenced_document_list_invalid_error::ReferencedDocumentListInvalidError;
159
173
  use dpp::consensus::state::voting::masternode_incorrect_voter_identity_id_error::MasternodeIncorrectVoterIdentityIdError;
160
174
  use dpp::consensus::state::voting::masternode_incorrect_voting_address_error::MasternodeIncorrectVotingAddressError;
161
175
  use dpp::consensus::state::voting::masternode_not_found_error::MasternodeNotFoundError;
162
176
  use dpp::consensus::state::voting::masternode_vote_already_present_error::MasternodeVoteAlreadyPresentError;
163
177
  use dpp::consensus::state::voting::masternode_voted_too_many_times::MasternodeVotedTooManyTimesError;
164
178
  use dpp::consensus::state::voting::vote_poll_not_available_for_voting_error::VotePollNotAvailableForVotingError;
179
+ use dpp::consensus::state::voting::vote_choice_not_allowed_for_vote_poll_error::VoteChoiceNotAllowedForVotePollError;
165
180
  use dpp::consensus::state::voting::vote_poll_not_found_error::VotePollNotFoundError;
166
181
 
167
182
  use crate::errors::consensus::basic::data_contract::{
@@ -656,6 +671,60 @@ pub fn from_state_error(state_error: &StateError) -> JsValue {
656
671
  StateError::DocumentModerationWindowElapsedError(e) => {
657
672
  generic_consensus_error!(DocumentModerationWindowElapsedError, e).into()
658
673
  }
674
+ StateError::ContractDocumentRemovalNotFoundError(e) => {
675
+ generic_consensus_error!(ContractDocumentRemovalNotFoundError, e).into()
676
+ }
677
+ StateError::DocumentRestoreWindowElapsedError(e) => {
678
+ generic_consensus_error!(DocumentRestoreWindowElapsedError, e).into()
679
+ }
680
+ StateError::DocumentRestoreHashMismatchError(e) => {
681
+ generic_consensus_error!(DocumentRestoreHashMismatchError, e).into()
682
+ }
683
+ StateError::ContractDocumentAlreadyRestoredError(e) => {
684
+ generic_consensus_error!(ContractDocumentAlreadyRestoredError, e).into()
685
+ }
686
+ StateError::ContractUserNotWarnedError(e) => {
687
+ generic_consensus_error!(ContractUserNotWarnedError, e).into()
688
+ }
689
+ StateError::ContractUserWarningLimitReachedError(e) => {
690
+ generic_consensus_error!(ContractUserWarningLimitReachedError, e).into()
691
+ }
692
+ StateError::ContractModeratedDocumentTypeNotYetUsableError(e) => {
693
+ generic_consensus_error!(ContractModeratedDocumentTypeNotYetUsableError, e).into()
694
+ }
695
+ StateError::VoteChoiceNotAllowedForVotePollError(e) => {
696
+ generic_consensus_error!(VoteChoiceNotAllowedForVotePollError, e).into()
697
+ }
698
+ StateError::ReferencedContractRequirementNotMetError(e) => {
699
+ generic_consensus_error!(ReferencedContractRequirementNotMetError, e).into()
700
+ }
701
+ StateError::ReferencedIdentityKeyRequirementNotMetError(e) => {
702
+ generic_consensus_error!(ReferencedIdentityKeyRequirementNotMetError, e).into()
703
+ }
704
+ StateError::ReferencedDocumentLookupInvalidError(e) => {
705
+ generic_consensus_error!(ReferencedDocumentLookupInvalidError, e).into()
706
+ }
707
+ StateError::ReferencedDocumentListInvalidError(e) => {
708
+ generic_consensus_error!(ReferencedDocumentListInvalidError, e).into()
709
+ }
710
+ StateError::ContractModerationAbilityNotGrantedError(e) => {
711
+ generic_consensus_error!(ContractModerationAbilityNotGrantedError, e).into()
712
+ }
713
+ StateError::ModerationCharterAddedModeratorLimitReachedError(e) => {
714
+ generic_consensus_error!(ModerationCharterAddedModeratorLimitReachedError, e).into()
715
+ }
716
+ StateError::ModerationReasonNotListedError(e) => {
717
+ generic_consensus_error!(ModerationReasonNotListedError, e).into()
718
+ }
719
+ StateError::DocumentActionFeeModeratorsShareMismatchError(e) => {
720
+ generic_consensus_error!(DocumentActionFeeModeratorsShareMismatchError, e).into()
721
+ }
722
+ StateError::DocumentExpiredError(e) => {
723
+ generic_consensus_error!(DocumentExpiredError, e).into()
724
+ }
725
+ StateError::DocumentContestMaximumContendersReachedError(e) => {
726
+ generic_consensus_error!(DocumentContestMaximumContendersReachedError, e).into()
727
+ }
659
728
  }
660
729
  }
661
730
 
@@ -912,6 +981,9 @@ fn from_basic_error(basic_error: &BasicError) -> JsValue {
912
981
  BasicError::DocumentFieldMaxSizeExceededError(e) => {
913
982
  generic_consensus_error!(DocumentFieldMaxSizeExceededError, e).into()
914
983
  }
984
+ BasicError::DocumentPropertyNotDistinctError(e) => {
985
+ generic_consensus_error!(DocumentPropertyNotDistinctError, e).into()
986
+ }
915
987
  BasicError::ContestedUniqueIndexWithUniqueIndexError(e) => {
916
988
  generic_consensus_error!(ContestedUniqueIndexWithUniqueIndexError, e).into()
917
989
  }
@@ -1230,6 +1302,24 @@ fn from_basic_error(basic_error: &BasicError) -> JsValue {
1230
1302
  BasicError::ContractModerationReasonTooLongError(e) => {
1231
1303
  generic_consensus_error!(ContractModerationReasonTooLongError, e).into()
1232
1304
  }
1305
+ BasicError::ModerationCharterMalformedFieldError(e) => {
1306
+ generic_consensus_error!(ModerationCharterMalformedFieldError, e).into()
1307
+ }
1308
+ BasicError::ModerationCharterRewardSplitNotOneHundredError(e) => {
1309
+ generic_consensus_error!(ModerationCharterRewardSplitNotOneHundredError, e).into()
1310
+ }
1311
+ BasicError::InvalidContractModerationReasonDocumentsError(e) => {
1312
+ generic_consensus_error!(InvalidContractModerationReasonDocumentsError, e).into()
1313
+ }
1314
+ BasicError::InvalidEncryptedPropertyShapeError(e) => {
1315
+ generic_consensus_error!(InvalidEncryptedPropertyShapeError, e).into()
1316
+ }
1317
+ BasicError::DocumentPropertyMaxBytesExceededError(e) => {
1318
+ generic_consensus_error!(DocumentPropertyMaxBytesExceededError, e).into()
1319
+ }
1320
+ BasicError::DocumentPropertyConstraintViolatedError(e) => {
1321
+ generic_consensus_error!(DocumentPropertyConstraintViolatedError, e).into()
1322
+ }
1233
1323
  }
1234
1324
  }
1235
1325
 
@@ -72,7 +72,9 @@ describe('DataContractCreateTransition', () => {
72
72
  it('should return serialized State Transition', () => {
73
73
  const result = stateTransition.toBuffer();
74
74
  expect(result).to.be.instanceOf(Buffer);
75
- expect(result).to.have.lengthOf(2370);
75
+ // The fixture contract carries a V2 config (protocol version 14), whose optional
76
+ // moderation declaration is one more bincode byte than a V1 config.
77
+ expect(result).to.have.lengthOf(2371);
76
78
  });
77
79
 
78
80
  it('should be able to restore contract config from bytes', () => {
@@ -66,7 +66,9 @@ describe('DataContractUpdateTransition', () => {
66
66
  it('should return serialized State Transition', () => {
67
67
  const result = stateTransition.toBuffer();
68
68
  expect(result).to.be.instanceOf(Buffer);
69
- expect(result).to.have.lengthOf(2370);
69
+ // The fixture contract carries a V2 config (protocol version 14), whose optional
70
+ // moderation declaration is one more bincode byte than a V1 config.
71
+ expect(result).to.have.lengthOf(2371);
70
72
  });
71
73
 
72
74
  it('should be able to restore contract config from bytes', () => {