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

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.4",
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.4",
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;
@@ -91,21 +91,28 @@ use dpp::consensus::basic::contract_group::{
91
91
  InvalidContractGroupAdminsError, RedundantContractGroupMembershipError,
92
92
  };
93
93
  use dpp::consensus::basic::contract_moderation::{
94
- ContractModerationReasonTooLongError, ContractModerationSelfTargetError,
94
+ ContractModerationReasonTooLongError, InvalidContractModerationReasonDocumentsError, ContractModerationSelfTargetError,
95
95
  DocumentActionFeesWithoutModerationError,
96
96
  InvalidContractModerationConfigError,
97
97
  };
98
+ use dpp::consensus::basic::moderation_charter::{
99
+ ModerationCharterMalformedFieldError, ModerationCharterRewardSplitNotOneHundredError,
100
+ };
98
101
  use dpp::consensus::state::contract_moderation::{
99
102
  ContractFeeClaimNotAllowedError, ContractFeesAlreadyClaimedThisEpochError,
100
- ContractFeesNothingToClaimError,
103
+ ContractFeesNothingToClaimError, ContractModeratedDocumentTypeNotYetUsableError,
104
+ ContractModerationAbilityNotGrantedError, ModerationCharterAddedModeratorLimitReachedError,
105
+ ModerationReasonNotListedError,
101
106
  ContractModerationNotEnabledError, ContractModerationTargetNotAllowedError,
102
107
  ContractModerationCounterpartyBarredError, ContractModerationTargetNotFoundError,
103
108
  ContractModeratorIdentityNotFoundError,
104
109
  ContractSuspensionNotInFutureError,
105
110
  ContractUserAlreadyBannedError, ContractUserBannedError, ContractUserNotBannedError,
106
- ContractUserNotSuspendedError, ContractUserSuspendedError,
107
- DocumentModerationWindowElapsedError, DocumentTypeNotDeletableByModeratorsError,
108
- IdentityNotContractModeratorError,
111
+ ContractUserNotSuspendedError, ContractUserNotWarnedError, ContractUserSuspendedError,
112
+ ContractUserWarningLimitReachedError, ContractDocumentAlreadyRestoredError,
113
+ ContractDocumentRemovalNotFoundError, DocumentModerationWindowElapsedError,
114
+ DocumentRestoreHashMismatchError, DocumentRestoreWindowElapsedError,
115
+ DocumentTypeNotDeletableByModeratorsError, IdentityNotContractModeratorError,
109
116
  };
110
117
  use dpp::consensus::state::contract_group::{
111
118
  ContractGroupAdminNotFoundError, ContractGroupAlreadyExistsError, ContractGroupNotFoundError,
@@ -146,6 +153,7 @@ use dpp::consensus::state::document::document_immutable_property_changed_error::
146
153
  use dpp::consensus::state::identity::gas_sponsor_insufficient_balance_error::GasSponsorInsufficientBalanceError;
147
154
  use dpp::consensus::state::token::{GasFeesPaidByNotAllowedError, InconsistentGasFeesPaidByInBatchError};
148
155
  use dpp::consensus::state::document::document_action_fee_agreement_mismatch_error::DocumentActionFeeAgreementMismatchError;
156
+ use dpp::consensus::state::document::document_action_fee_moderators_share_mismatch_error::DocumentActionFeeModeratorsShareMismatchError;
149
157
  use dpp::consensus::state::document::document_action_fee_agreement_not_set_error::DocumentActionFeeAgreementNotSetError;
150
158
  use dpp::consensus::state::document::document_action_fee_multiplier_not_tolerated_error::DocumentActionFeeMultiplierNotToleratedError;
151
159
  use dpp::consensus::state::document::referenced_key_id_property_invalid_error::ReferencedKeyIdPropertyInvalidError;
@@ -156,12 +164,17 @@ use dpp::consensus::state::shielded::invalid_anchor_error::InvalidAnchorError;
156
164
  use dpp::consensus::state::shielded::invalid_shielded_proof_error::InvalidShieldedProofError;
157
165
  use dpp::consensus::state::shielded::nullifier_already_spent_error::NullifierAlreadySpentError;
158
166
  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};
167
+ use dpp::consensus::state::document::referenced_contract_requirement_not_met_error::ReferencedContractRequirementNotMetError;
168
+ use dpp::consensus::state::document::referenced_identity_key_requirement_not_met_error::ReferencedIdentityKeyRequirementNotMetError;
169
+ use dpp::consensus::state::document::referenced_document_lookup_invalid_error::ReferencedDocumentLookupInvalidError;
170
+ use dpp::consensus::state::document::referenced_document_list_invalid_error::ReferencedDocumentListInvalidError;
159
171
  use dpp::consensus::state::voting::masternode_incorrect_voter_identity_id_error::MasternodeIncorrectVoterIdentityIdError;
160
172
  use dpp::consensus::state::voting::masternode_incorrect_voting_address_error::MasternodeIncorrectVotingAddressError;
161
173
  use dpp::consensus::state::voting::masternode_not_found_error::MasternodeNotFoundError;
162
174
  use dpp::consensus::state::voting::masternode_vote_already_present_error::MasternodeVoteAlreadyPresentError;
163
175
  use dpp::consensus::state::voting::masternode_voted_too_many_times::MasternodeVotedTooManyTimesError;
164
176
  use dpp::consensus::state::voting::vote_poll_not_available_for_voting_error::VotePollNotAvailableForVotingError;
177
+ use dpp::consensus::state::voting::vote_choice_not_allowed_for_vote_poll_error::VoteChoiceNotAllowedForVotePollError;
165
178
  use dpp::consensus::state::voting::vote_poll_not_found_error::VotePollNotFoundError;
166
179
 
167
180
  use crate::errors::consensus::basic::data_contract::{
@@ -656,6 +669,54 @@ pub fn from_state_error(state_error: &StateError) -> JsValue {
656
669
  StateError::DocumentModerationWindowElapsedError(e) => {
657
670
  generic_consensus_error!(DocumentModerationWindowElapsedError, e).into()
658
671
  }
672
+ StateError::ContractDocumentRemovalNotFoundError(e) => {
673
+ generic_consensus_error!(ContractDocumentRemovalNotFoundError, e).into()
674
+ }
675
+ StateError::DocumentRestoreWindowElapsedError(e) => {
676
+ generic_consensus_error!(DocumentRestoreWindowElapsedError, e).into()
677
+ }
678
+ StateError::DocumentRestoreHashMismatchError(e) => {
679
+ generic_consensus_error!(DocumentRestoreHashMismatchError, e).into()
680
+ }
681
+ StateError::ContractDocumentAlreadyRestoredError(e) => {
682
+ generic_consensus_error!(ContractDocumentAlreadyRestoredError, e).into()
683
+ }
684
+ StateError::ContractUserNotWarnedError(e) => {
685
+ generic_consensus_error!(ContractUserNotWarnedError, e).into()
686
+ }
687
+ StateError::ContractUserWarningLimitReachedError(e) => {
688
+ generic_consensus_error!(ContractUserWarningLimitReachedError, e).into()
689
+ }
690
+ StateError::ContractModeratedDocumentTypeNotYetUsableError(e) => {
691
+ generic_consensus_error!(ContractModeratedDocumentTypeNotYetUsableError, e).into()
692
+ }
693
+ StateError::VoteChoiceNotAllowedForVotePollError(e) => {
694
+ generic_consensus_error!(VoteChoiceNotAllowedForVotePollError, e).into()
695
+ }
696
+ StateError::ReferencedContractRequirementNotMetError(e) => {
697
+ generic_consensus_error!(ReferencedContractRequirementNotMetError, e).into()
698
+ }
699
+ StateError::ReferencedIdentityKeyRequirementNotMetError(e) => {
700
+ generic_consensus_error!(ReferencedIdentityKeyRequirementNotMetError, e).into()
701
+ }
702
+ StateError::ReferencedDocumentLookupInvalidError(e) => {
703
+ generic_consensus_error!(ReferencedDocumentLookupInvalidError, e).into()
704
+ }
705
+ StateError::ReferencedDocumentListInvalidError(e) => {
706
+ generic_consensus_error!(ReferencedDocumentListInvalidError, e).into()
707
+ }
708
+ StateError::ContractModerationAbilityNotGrantedError(e) => {
709
+ generic_consensus_error!(ContractModerationAbilityNotGrantedError, e).into()
710
+ }
711
+ StateError::ModerationCharterAddedModeratorLimitReachedError(e) => {
712
+ generic_consensus_error!(ModerationCharterAddedModeratorLimitReachedError, e).into()
713
+ }
714
+ StateError::ModerationReasonNotListedError(e) => {
715
+ generic_consensus_error!(ModerationReasonNotListedError, e).into()
716
+ }
717
+ StateError::DocumentActionFeeModeratorsShareMismatchError(e) => {
718
+ generic_consensus_error!(DocumentActionFeeModeratorsShareMismatchError, e).into()
719
+ }
659
720
  }
660
721
  }
661
722
 
@@ -912,6 +973,9 @@ fn from_basic_error(basic_error: &BasicError) -> JsValue {
912
973
  BasicError::DocumentFieldMaxSizeExceededError(e) => {
913
974
  generic_consensus_error!(DocumentFieldMaxSizeExceededError, e).into()
914
975
  }
976
+ BasicError::DocumentPropertyNotDistinctError(e) => {
977
+ generic_consensus_error!(DocumentPropertyNotDistinctError, e).into()
978
+ }
915
979
  BasicError::ContestedUniqueIndexWithUniqueIndexError(e) => {
916
980
  generic_consensus_error!(ContestedUniqueIndexWithUniqueIndexError, e).into()
917
981
  }
@@ -1230,6 +1294,24 @@ fn from_basic_error(basic_error: &BasicError) -> JsValue {
1230
1294
  BasicError::ContractModerationReasonTooLongError(e) => {
1231
1295
  generic_consensus_error!(ContractModerationReasonTooLongError, e).into()
1232
1296
  }
1297
+ BasicError::ModerationCharterMalformedFieldError(e) => {
1298
+ generic_consensus_error!(ModerationCharterMalformedFieldError, e).into()
1299
+ }
1300
+ BasicError::ModerationCharterRewardSplitNotOneHundredError(e) => {
1301
+ generic_consensus_error!(ModerationCharterRewardSplitNotOneHundredError, e).into()
1302
+ }
1303
+ BasicError::InvalidContractModerationReasonDocumentsError(e) => {
1304
+ generic_consensus_error!(InvalidContractModerationReasonDocumentsError, e).into()
1305
+ }
1306
+ BasicError::InvalidEncryptedPropertyShapeError(e) => {
1307
+ generic_consensus_error!(InvalidEncryptedPropertyShapeError, e).into()
1308
+ }
1309
+ BasicError::DocumentPropertyMaxBytesExceededError(e) => {
1310
+ generic_consensus_error!(DocumentPropertyMaxBytesExceededError, e).into()
1311
+ }
1312
+ BasicError::DocumentPropertyConstraintViolatedError(e) => {
1313
+ generic_consensus_error!(DocumentPropertyConstraintViolatedError, e).into()
1314
+ }
1233
1315
  }
1234
1316
  }
1235
1317
 
@@ -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', () => {