@dashevo/wasm-dpp 1.8.0 → 2.0.0-dev.1
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/.eslintrc +3 -0
- package/Cargo.toml +3 -2
- package/dist/wasm/wasm_dpp.d.ts +1824 -1070
- package/dist/wasm/wasm_dpp.js +597 -168
- package/dist/wasm/wasm_dpp_bg.js +1 -1
- package/lib/test/fixtures/getIdentityCreditTransferTransitionFixture.js +1 -1
- package/lib/test/fixtures/getIdentityFixture.js +1 -1
- package/lib/wasm/wasm_dpp.d.ts +1824 -1070
- package/package.json +6 -6
- package/scripts/build-wasm.sh +1 -1
- package/src/data_contract/data_contract.rs +17 -22
- package/src/data_contract/mod.rs +1 -0
- package/src/data_contract/state_transition/data_contract_create_transition/mod.rs +21 -0
- package/src/data_contract/state_transition/data_contract_update_transition/mod.rs +25 -0
- package/src/data_contract/tokens.rs +60 -0
- package/src/document/document_facade.rs +3 -3
- package/src/document/errors/document_already_exists_error.rs +1 -1
- package/src/document/errors/document_not_provided_error.rs +1 -1
- package/src/document/errors/invalid_document_action_error.rs +2 -2
- package/src/document/extended_document.rs +3 -5
- package/src/document/factory.rs +14 -8
- package/src/document/mod.rs +3 -5
- package/src/document/state_transition/batch_transition/batched_transition/mod.rs +18 -0
- package/src/document/state_transition/{document_batch_transition → batch_transition}/document_transition/document_create_transition.rs +45 -3
- package/src/document/state_transition/{document_batch_transition → batch_transition}/document_transition/document_delete_transition.rs +23 -4
- package/src/document/state_transition/{document_batch_transition → batch_transition}/document_transition/document_replace_transition.rs +24 -5
- package/src/document/state_transition/{document_batch_transition → batch_transition}/document_transition/mod.rs +99 -14
- package/src/document/state_transition/{document_batch_transition → batch_transition}/mod.rs +45 -29
- package/src/document/state_transition/batch_transition/token_transition/burn.rs +12 -0
- package/src/document/state_transition/batch_transition/token_transition/claim.rs +12 -0
- package/src/document/state_transition/batch_transition/token_transition/config.rs +12 -0
- package/src/document/state_transition/batch_transition/token_transition/destroy.rs +22 -0
- package/src/document/state_transition/batch_transition/token_transition/emergency_action.rs +12 -0
- package/src/document/state_transition/batch_transition/token_transition/freeze.rs +22 -0
- package/src/document/state_transition/batch_transition/token_transition/mint.rs +31 -0
- package/src/document/state_transition/batch_transition/token_transition/mod.rs +147 -0
- package/src/document/state_transition/batch_transition/token_transition/transfer.rs +22 -0
- package/src/document/state_transition/batch_transition/token_transition/unfreeze.rs +22 -0
- package/src/document/state_transition/mod.rs +1 -1
- package/src/errors/consensus/basic/identity/identity_insufficient_balance_error.rs +2 -2
- package/src/errors/consensus/consensus_error.rs +167 -1
- package/src/errors/consensus/fee/balance_is_not_enough_error.rs +4 -4
- package/src/identity/identity.rs +14 -14
- package/src/identity/state_transition/identity_create_transition/identity_create_transition.rs +10 -0
- package/src/identity/state_transition/identity_credit_transfer_transition/transition.rs +31 -6
- package/src/identity/state_transition/identity_credit_withdrawal_transition/transition.rs +15 -0
- package/src/identity/state_transition/identity_topup_transition/identity_topup_transition.rs +10 -0
- package/src/identity/state_transition/identity_update_transition/identity_update_transition.rs +29 -4
- package/src/identity/state_transition/identity_update_transition/to_object.rs +2 -2
- package/src/identity/state_transition/transition_types.rs +1 -1
- package/src/metadata.rs +16 -27
- package/src/state_transition/state_transition_factory.rs +2 -4
- package/src/voting/state_transition/masternode_vote_transition/mod.rs +75 -50
- package/test/integration/document/Document.spec.js +2 -7
- package/test/integration/document/DocumentFacade.spec.js +4 -4
- package/test/integration/identity/IdentityFacade.spec.js +5 -10
- package/test/integration/identity/stateTransition/IdentityUpdateTransition/validation/state/validateIdentityUpdateTransitionStateFactory.spec.js +4 -4
- package/test/integration/identity/stateTransition/assetLockProof/chain/validateChainAssetLockProofStructureFactory.spec.js +3 -3
- package/test/integration/identity/stateTransition/assetLockProof/fetchAssetLockTransactionOutputFactory.spec.js +1 -1
- package/test/integration/stateTransition/StateTransitionFacade.spec.js +3 -3
- package/test/unit/Metadata.spec.js +8 -23
- package/test/unit/dataContract/DataContract.spec.js +1 -18
- package/test/unit/dataContract/stateTransition/DataContractCreateTransition/DataContractCreateTransition.spec.js +1 -1
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/DataContractUpdateTransition.spec.js +1 -1
- package/test/unit/document/Document.spec.js +4 -7
- package/test/unit/document/DocumentFactory.spec.js +2 -2
- package/test/unit/identity/Identity.spec.js +15 -35
- package/test/unit/identity/IdentityFactory.spec.js +3 -3
- package/test/unit/identity/stateTransition/IdentityUpdateTransition/IdentityUpdateTransition.spec.js +2 -2
- package/test/unit/identity/stateTransition/identityCreditTransferTransition/identityCreditTransferTransition.spec.js +1 -1
- /package/src/document/state_transition/{document_batch_transition → batch_transition}/validation/basic/find_duplicates_by_id.rs +0 -0
- /package/src/document/state_transition/{document_batch_transition → batch_transition}/validation/basic/find_duplicates_by_indices.rs +0 -0
- /package/src/document/state_transition/{document_batch_transition → batch_transition}/validation/basic/mod.rs +0 -0
- /package/src/document/state_transition/{document_batch_transition → batch_transition}/validation/basic/validate_documents_batch_transition_basic.rs +0 -0
- /package/src/document/state_transition/{document_batch_transition → batch_transition}/validation/basic/validate_partial_compound_indices.rs +0 -0
- /package/src/document/state_transition/{document_batch_transition → batch_transition}/validation/mod.rs +0 -0
- /package/src/document/state_transition/{document_batch_transition → batch_transition}/validation/state/fetch_extended_documents.rs +0 -0
- /package/src/document/state_transition/{document_batch_transition → batch_transition}/validation/state/mod.rs +0 -0
- /package/src/document/state_transition/{document_batch_transition → batch_transition}/validation/state/validate_documents_batch_transitions_state.rs +0 -0
- /package/src/document/state_transition/{document_batch_transition → batch_transition}/validation/state/validate_documents_uniqueness_by_indices.rs +0 -0
|
@@ -61,10 +61,13 @@ use dpp::consensus::state::data_trigger::DataTriggerError::{
|
|
|
61
61
|
DataTriggerConditionError, DataTriggerExecutionError, DataTriggerInvalidResultError,
|
|
62
62
|
};
|
|
63
63
|
use wasm_bindgen::{JsError, JsValue};
|
|
64
|
-
use dpp::consensus::basic::data_contract::{ContestedUniqueIndexOnMutableDocumentTypeError, ContestedUniqueIndexWithUniqueIndexError, InvalidDocumentTypeRequiredSecurityLevelError, UnknownDocumentCreationRestrictionModeError, UnknownSecurityLevelError, UnknownStorageKeyRequirementsError, UnknownTradeModeError, UnknownTransferableTypeError};
|
|
64
|
+
use dpp::consensus::basic::data_contract::{ContestedUniqueIndexOnMutableDocumentTypeError, ContestedUniqueIndexWithUniqueIndexError, DataContractTokenConfigurationUpdateError, GroupExceedsMaxMembersError, GroupMemberHasPowerOfZeroError, GroupMemberHasPowerOverLimitError, GroupNonUnilateralMemberPowerHasLessThanRequiredPowerError, GroupPositionDoesNotExistError, GroupTotalPowerLessThanRequiredError, InvalidDocumentTypeRequiredSecurityLevelError, InvalidTokenBaseSupplyError, InvalidTokenDistributionFunctionDivideByZeroError, InvalidTokenDistributionFunctionIncoherenceError, InvalidTokenDistributionFunctionInvalidParameterError, InvalidTokenDistributionFunctionInvalidParameterTupleError, NonContiguousContractGroupPositionsError, NonContiguousContractTokenPositionsError, UnknownDocumentCreationRestrictionModeError, UnknownSecurityLevelError, UnknownStorageKeyRequirementsError, UnknownTradeModeError, UnknownTransferableTypeError};
|
|
65
65
|
use dpp::consensus::basic::document::{ContestedDocumentsTemporarilyNotAllowedError, DocumentCreationNotAllowedError, DocumentFieldMaxSizeExceededError, MaxDocumentsTransitionsExceededError, MissingPositionsInDocumentTypePropertiesError};
|
|
66
|
+
use dpp::consensus::basic::group::GroupActionNotAllowedOnTransitionError;
|
|
66
67
|
use dpp::consensus::basic::identity::{DataContractBoundsNotPresentError, DisablingKeyIdAlsoBeingAddedInSameTransitionError, InvalidIdentityCreditWithdrawalTransitionAmountError, InvalidIdentityUpdateTransitionDisableKeysError, InvalidIdentityUpdateTransitionEmptyError, TooManyMasterPublicKeyError, WithdrawalOutputScriptNotAllowedWhenSigningWithOwnerKeyError};
|
|
67
68
|
use dpp::consensus::basic::overflow_error::OverflowError;
|
|
69
|
+
use dpp::consensus::basic::token::{ChoosingTokenMintRecipientNotAllowedError, ContractHasNoTokensError, DestinationIdentityForTokenMintingNotSetError, InvalidActionIdError, InvalidTokenAmountError, InvalidTokenConfigUpdateNoChangeError, InvalidTokenIdError, InvalidTokenNoteTooBigError, InvalidTokenPositionError, MissingDefaultLocalizationError, TokenTransferToOurselfError};
|
|
70
|
+
use dpp::consensus::state::data_contract::data_contract_update_action_not_allowed_error::DataContractUpdateActionNotAllowedError;
|
|
68
71
|
use dpp::consensus::state::data_contract::document_type_update_error::DocumentTypeUpdateError;
|
|
69
72
|
use dpp::consensus::state::document::document_contest_currently_locked_error::DocumentContestCurrentlyLockedError;
|
|
70
73
|
use dpp::consensus::state::document::document_contest_document_with_same_id_already_present_error::DocumentContestDocumentWithSameIdAlreadyPresentError;
|
|
@@ -73,12 +76,15 @@ use dpp::consensus::state::document::document_contest_not_joinable_error::Docume
|
|
|
73
76
|
use dpp::consensus::state::document::document_contest_not_paid_for_error::DocumentContestNotPaidForError;
|
|
74
77
|
use dpp::consensus::state::document::document_incorrect_purchase_price_error::DocumentIncorrectPurchasePriceError;
|
|
75
78
|
use dpp::consensus::state::document::document_not_for_sale_error::DocumentNotForSaleError;
|
|
79
|
+
use dpp::consensus::state::group::{GroupActionAlreadyCompletedError, GroupActionAlreadySignedByIdentityError, GroupActionDoesNotExistError, IdentityNotMemberOfGroupError};
|
|
76
80
|
use dpp::consensus::state::identity::identity_public_key_already_exists_for_unique_contract_bounds_error::IdentityPublicKeyAlreadyExistsForUniqueContractBoundsError;
|
|
77
81
|
use dpp::consensus::state::identity::master_public_key_update_error::MasterPublicKeyUpdateError;
|
|
78
82
|
use dpp::consensus::state::identity::missing_transfer_key_error::MissingTransferKeyError;
|
|
79
83
|
use dpp::consensus::state::identity::no_transfer_key_for_core_withdrawal_available_error::NoTransferKeyForCoreWithdrawalAvailableError;
|
|
84
|
+
use dpp::consensus::state::identity::RecipientIdentityDoesNotExistError;
|
|
80
85
|
use dpp::consensus::state::prefunded_specialized_balances::prefunded_specialized_balance_insufficient_error::PrefundedSpecializedBalanceInsufficientError;
|
|
81
86
|
use dpp::consensus::state::prefunded_specialized_balances::prefunded_specialized_balance_not_found_error::PrefundedSpecializedBalanceNotFoundError;
|
|
87
|
+
use dpp::consensus::state::token::{IdentityDoesNotHaveEnoughTokenBalanceError, IdentityTokenAccountNotFrozenError, IdentityTokenAccountFrozenError, TokenIsPausedError, IdentityTokenAccountAlreadyFrozenError, UnauthorizedTokenActionError, TokenSettingMaxSupplyToLessThanCurrentSupplyError, TokenMintPastMaxSupplyError, NewTokensDestinationIdentityDoesNotExistError, NewAuthorizedActionTakerIdentityDoesNotExistError, NewAuthorizedActionTakerGroupDoesNotExistError, NewAuthorizedActionTakerMainGroupNotSetError, InvalidGroupPositionError, TokenAlreadyPausedError, TokenNotPausedError, InvalidTokenClaimPropertyMismatch, InvalidTokenClaimNoCurrentRewards, InvalidTokenClaimWrongClaimant};
|
|
82
88
|
use dpp::consensus::state::voting::masternode_incorrect_voter_identity_id_error::MasternodeIncorrectVoterIdentityIdError;
|
|
83
89
|
use dpp::consensus::state::voting::masternode_incorrect_voting_address_error::MasternodeIncorrectVotingAddressError;
|
|
84
90
|
use dpp::consensus::state::voting::masternode_not_found_error::MasternodeNotFoundError;
|
|
@@ -308,6 +314,76 @@ pub fn from_state_error(state_error: &StateError) -> JsValue {
|
|
|
308
314
|
StateError::DocumentContestNotPaidForError(e) => {
|
|
309
315
|
generic_consensus_error!(DocumentContestNotPaidForError, e).into()
|
|
310
316
|
}
|
|
317
|
+
StateError::RecipientIdentityDoesNotExistError(e) => {
|
|
318
|
+
generic_consensus_error!(RecipientIdentityDoesNotExistError, e).into()
|
|
319
|
+
}
|
|
320
|
+
StateError::IdentityDoesNotHaveEnoughTokenBalanceError(e) => {
|
|
321
|
+
generic_consensus_error!(IdentityDoesNotHaveEnoughTokenBalanceError, e).into()
|
|
322
|
+
}
|
|
323
|
+
StateError::UnauthorizedTokenActionError(e) => {
|
|
324
|
+
generic_consensus_error!(UnauthorizedTokenActionError, e).into()
|
|
325
|
+
}
|
|
326
|
+
StateError::IdentityTokenAccountFrozenError(e) => {
|
|
327
|
+
generic_consensus_error!(IdentityTokenAccountFrozenError, e).into()
|
|
328
|
+
}
|
|
329
|
+
StateError::TokenIsPausedError(e) => generic_consensus_error!(TokenIsPausedError, e).into(),
|
|
330
|
+
StateError::IdentityTokenAccountAlreadyFrozenError(e) => {
|
|
331
|
+
generic_consensus_error!(IdentityTokenAccountAlreadyFrozenError, e).into()
|
|
332
|
+
}
|
|
333
|
+
StateError::TokenAlreadyPausedError(e) => {
|
|
334
|
+
generic_consensus_error!(TokenAlreadyPausedError, e).into()
|
|
335
|
+
}
|
|
336
|
+
StateError::TokenNotPausedError(e) => {
|
|
337
|
+
generic_consensus_error!(TokenNotPausedError, e).into()
|
|
338
|
+
}
|
|
339
|
+
StateError::IdentityNotMemberOfGroupError(e) => {
|
|
340
|
+
generic_consensus_error!(IdentityNotMemberOfGroupError, e).into()
|
|
341
|
+
}
|
|
342
|
+
StateError::GroupActionDoesNotExistError(e) => {
|
|
343
|
+
generic_consensus_error!(GroupActionDoesNotExistError, e).into()
|
|
344
|
+
}
|
|
345
|
+
StateError::GroupActionAlreadyCompletedError(e) => {
|
|
346
|
+
generic_consensus_error!(GroupActionAlreadyCompletedError, e).into()
|
|
347
|
+
}
|
|
348
|
+
StateError::GroupActionAlreadySignedByIdentityError(e) => {
|
|
349
|
+
generic_consensus_error!(GroupActionAlreadySignedByIdentityError, e).into()
|
|
350
|
+
}
|
|
351
|
+
StateError::IdentityTokenAccountNotFrozenError(e) => {
|
|
352
|
+
generic_consensus_error!(IdentityTokenAccountNotFrozenError, e).into()
|
|
353
|
+
}
|
|
354
|
+
StateError::DataContractUpdateActionNotAllowedError(e) => {
|
|
355
|
+
generic_consensus_error!(DataContractUpdateActionNotAllowedError, e).into()
|
|
356
|
+
}
|
|
357
|
+
StateError::TokenSettingMaxSupplyToLessThanCurrentSupplyError(e) => {
|
|
358
|
+
generic_consensus_error!(TokenSettingMaxSupplyToLessThanCurrentSupplyError, e).into()
|
|
359
|
+
}
|
|
360
|
+
StateError::TokenMintPastMaxSupplyError(e) => {
|
|
361
|
+
generic_consensus_error!(TokenMintPastMaxSupplyError, e).into()
|
|
362
|
+
}
|
|
363
|
+
StateError::NewTokensDestinationIdentityDoesNotExistError(e) => {
|
|
364
|
+
generic_consensus_error!(NewTokensDestinationIdentityDoesNotExistError, e).into()
|
|
365
|
+
}
|
|
366
|
+
StateError::NewAuthorizedActionTakerIdentityDoesNotExistError(e) => {
|
|
367
|
+
generic_consensus_error!(NewAuthorizedActionTakerIdentityDoesNotExistError, e).into()
|
|
368
|
+
}
|
|
369
|
+
StateError::NewAuthorizedActionTakerGroupDoesNotExistError(e) => {
|
|
370
|
+
generic_consensus_error!(NewAuthorizedActionTakerGroupDoesNotExistError, e).into()
|
|
371
|
+
}
|
|
372
|
+
StateError::NewAuthorizedActionTakerMainGroupNotSetError(e) => {
|
|
373
|
+
generic_consensus_error!(NewAuthorizedActionTakerMainGroupNotSetError, e).into()
|
|
374
|
+
}
|
|
375
|
+
StateError::InvalidGroupPositionError(e) => {
|
|
376
|
+
generic_consensus_error!(InvalidGroupPositionError, e).into()
|
|
377
|
+
}
|
|
378
|
+
StateError::InvalidTokenClaimPropertyMismatch(e) => {
|
|
379
|
+
generic_consensus_error!(InvalidTokenClaimPropertyMismatch, e).into()
|
|
380
|
+
}
|
|
381
|
+
StateError::InvalidTokenClaimNoCurrentRewards(e) => {
|
|
382
|
+
generic_consensus_error!(InvalidTokenClaimNoCurrentRewards, e).into()
|
|
383
|
+
}
|
|
384
|
+
StateError::InvalidTokenClaimWrongClaimant(e) => {
|
|
385
|
+
generic_consensus_error!(InvalidTokenClaimWrongClaimant, e).into()
|
|
386
|
+
}
|
|
311
387
|
}
|
|
312
388
|
}
|
|
313
389
|
|
|
@@ -571,6 +647,96 @@ fn from_basic_error(basic_error: &BasicError) -> JsValue {
|
|
|
571
647
|
)
|
|
572
648
|
.into()
|
|
573
649
|
}
|
|
650
|
+
BasicError::DataContractTokenConfigurationUpdateError(e) => {
|
|
651
|
+
generic_consensus_error!(DataContractTokenConfigurationUpdateError, e).into()
|
|
652
|
+
}
|
|
653
|
+
BasicError::InvalidTokenIdError(e) => {
|
|
654
|
+
generic_consensus_error!(InvalidTokenIdError, e).into()
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
BasicError::InvalidTokenPositionError(e) => {
|
|
658
|
+
generic_consensus_error!(InvalidTokenPositionError, e).into()
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
BasicError::ContractHasNoTokensError(e) => {
|
|
662
|
+
generic_consensus_error!(ContractHasNoTokensError, e).into()
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
BasicError::InvalidActionIdError(e) => {
|
|
666
|
+
generic_consensus_error!(InvalidActionIdError, e).into()
|
|
667
|
+
}
|
|
668
|
+
BasicError::NonContiguousContractTokenPositionsError(e) => {
|
|
669
|
+
generic_consensus_error!(NonContiguousContractTokenPositionsError, e).into()
|
|
670
|
+
}
|
|
671
|
+
BasicError::NonContiguousContractGroupPositionsError(e) => {
|
|
672
|
+
generic_consensus_error!(NonContiguousContractGroupPositionsError, e).into()
|
|
673
|
+
}
|
|
674
|
+
BasicError::InvalidTokenBaseSupplyError(e) => {
|
|
675
|
+
generic_consensus_error!(InvalidTokenBaseSupplyError, e).into()
|
|
676
|
+
}
|
|
677
|
+
BasicError::TokenTransferToOurselfError(e) => {
|
|
678
|
+
generic_consensus_error!(TokenTransferToOurselfError, e).into()
|
|
679
|
+
}
|
|
680
|
+
BasicError::DestinationIdentityForTokenMintingNotSetError(e) => {
|
|
681
|
+
generic_consensus_error!(DestinationIdentityForTokenMintingNotSetError, e).into()
|
|
682
|
+
}
|
|
683
|
+
BasicError::ChoosingTokenMintRecipientNotAllowedError(e) => {
|
|
684
|
+
generic_consensus_error!(ChoosingTokenMintRecipientNotAllowedError, e).into()
|
|
685
|
+
}
|
|
686
|
+
BasicError::GroupActionNotAllowedOnTransitionError(e) => {
|
|
687
|
+
generic_consensus_error!(GroupActionNotAllowedOnTransitionError, e).into()
|
|
688
|
+
}
|
|
689
|
+
BasicError::GroupPositionDoesNotExistError(e) => {
|
|
690
|
+
generic_consensus_error!(GroupPositionDoesNotExistError, e).into()
|
|
691
|
+
}
|
|
692
|
+
BasicError::GroupExceedsMaxMembersError(e) => {
|
|
693
|
+
generic_consensus_error!(GroupExceedsMaxMembersError, e).into()
|
|
694
|
+
}
|
|
695
|
+
BasicError::GroupMemberHasPowerOfZeroError(e) => {
|
|
696
|
+
generic_consensus_error!(GroupMemberHasPowerOfZeroError, e).into()
|
|
697
|
+
}
|
|
698
|
+
BasicError::GroupMemberHasPowerOverLimitError(e) => {
|
|
699
|
+
generic_consensus_error!(GroupMemberHasPowerOverLimitError, e).into()
|
|
700
|
+
}
|
|
701
|
+
BasicError::GroupTotalPowerLessThanRequiredError(e) => {
|
|
702
|
+
generic_consensus_error!(GroupTotalPowerLessThanRequiredError, e).into()
|
|
703
|
+
}
|
|
704
|
+
BasicError::GroupNonUnilateralMemberPowerHasLessThanRequiredPowerError(e) => {
|
|
705
|
+
generic_consensus_error!(
|
|
706
|
+
GroupNonUnilateralMemberPowerHasLessThanRequiredPowerError,
|
|
707
|
+
e
|
|
708
|
+
)
|
|
709
|
+
.into()
|
|
710
|
+
}
|
|
711
|
+
BasicError::InvalidTokenAmountError(e) => {
|
|
712
|
+
generic_consensus_error!(InvalidTokenAmountError, e).into()
|
|
713
|
+
}
|
|
714
|
+
BasicError::InvalidTokenConfigUpdateNoChangeError(e) => {
|
|
715
|
+
generic_consensus_error!(InvalidTokenConfigUpdateNoChangeError, e).into()
|
|
716
|
+
}
|
|
717
|
+
BasicError::InvalidTokenDistributionFunctionDivideByZeroError(e) => {
|
|
718
|
+
generic_consensus_error!(InvalidTokenDistributionFunctionDivideByZeroError, e).into()
|
|
719
|
+
}
|
|
720
|
+
BasicError::InvalidTokenDistributionFunctionInvalidParameterError(e) => {
|
|
721
|
+
generic_consensus_error!(InvalidTokenDistributionFunctionInvalidParameterError, e)
|
|
722
|
+
.into()
|
|
723
|
+
}
|
|
724
|
+
BasicError::InvalidTokenDistributionFunctionInvalidParameterTupleError(e) => {
|
|
725
|
+
generic_consensus_error!(
|
|
726
|
+
InvalidTokenDistributionFunctionInvalidParameterTupleError,
|
|
727
|
+
e
|
|
728
|
+
)
|
|
729
|
+
.into()
|
|
730
|
+
}
|
|
731
|
+
BasicError::InvalidTokenDistributionFunctionIncoherenceError(e) => {
|
|
732
|
+
generic_consensus_error!(InvalidTokenDistributionFunctionIncoherenceError, e).into()
|
|
733
|
+
}
|
|
734
|
+
BasicError::InvalidTokenNoteTooBigError(e) => {
|
|
735
|
+
generic_consensus_error!(InvalidTokenNoteTooBigError, e).into()
|
|
736
|
+
}
|
|
737
|
+
BasicError::MissingDefaultLocalizationError(e) => {
|
|
738
|
+
generic_consensus_error!(MissingDefaultLocalizationError, e).into()
|
|
739
|
+
}
|
|
574
740
|
}
|
|
575
741
|
}
|
|
576
742
|
|
|
@@ -29,13 +29,13 @@ impl BalanceIsNotEnoughErrorWasm {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
#[wasm_bindgen(js_name=getBalance)]
|
|
32
|
-
pub fn get_balance(&self) ->
|
|
33
|
-
self.inner.balance()
|
|
32
|
+
pub fn get_balance(&self) -> u64 {
|
|
33
|
+
self.inner.balance()
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
#[wasm_bindgen(js_name=getFee)]
|
|
37
|
-
pub fn get_fee(&self) ->
|
|
38
|
-
self.inner.fee() as
|
|
37
|
+
pub fn get_fee(&self) -> u64 {
|
|
38
|
+
self.inner.fee() as u64
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
#[wasm_bindgen(js_name=getCode)]
|
package/src/identity/identity.rs
CHANGED
|
@@ -105,38 +105,38 @@ impl IdentityWasm {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
#[wasm_bindgen(getter)]
|
|
108
|
-
pub fn balance(&self) ->
|
|
109
|
-
self.inner.balance()
|
|
108
|
+
pub fn balance(&self) -> u64 {
|
|
109
|
+
self.inner.balance()
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
#[wasm_bindgen(js_name=getBalance)]
|
|
113
|
-
pub fn get_balance(&self) ->
|
|
114
|
-
self.inner.balance()
|
|
113
|
+
pub fn get_balance(&self) -> u64 {
|
|
114
|
+
self.inner.balance()
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
#[wasm_bindgen(js_name=setBalance)]
|
|
118
|
-
pub fn set_balance(&mut self, balance:
|
|
119
|
-
self.inner.set_balance(balance
|
|
118
|
+
pub fn set_balance(&mut self, balance: u64) {
|
|
119
|
+
self.inner.set_balance(balance);
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
#[wasm_bindgen(js_name=increaseBalance)]
|
|
123
|
-
pub fn increase_balance(&mut self, amount:
|
|
124
|
-
self.inner.increase_balance(amount
|
|
123
|
+
pub fn increase_balance(&mut self, amount: u64) -> u64 {
|
|
124
|
+
self.inner.increase_balance(amount)
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
#[wasm_bindgen(js_name=reduceBalance)]
|
|
128
|
-
pub fn reduce_balance(&mut self, amount:
|
|
129
|
-
self.inner.reduce_balance(amount
|
|
128
|
+
pub fn reduce_balance(&mut self, amount: u64) -> u64 {
|
|
129
|
+
self.inner.reduce_balance(amount)
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
#[wasm_bindgen(js_name=setRevision)]
|
|
133
|
-
pub fn set_revision(&mut self, revision:
|
|
134
|
-
self.inner.set_revision(revision
|
|
133
|
+
pub fn set_revision(&mut self, revision: u64) {
|
|
134
|
+
self.inner.set_revision(revision);
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
#[wasm_bindgen(js_name=getRevision)]
|
|
138
|
-
pub fn get_revision(&self) ->
|
|
139
|
-
self.inner.revision() as
|
|
138
|
+
pub fn get_revision(&self) -> u64 {
|
|
139
|
+
self.inner.revision() as u64
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
#[wasm_bindgen(js_name=setMetadata)]
|
package/src/identity/state_transition/identity_create_transition/identity_create_transition.rs
CHANGED
|
@@ -167,6 +167,16 @@ impl IdentityCreateTransitionWasm {
|
|
|
167
167
|
(IdentityCreateTransitionAccessorsV0::owner_id(&self.0)).into()
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
+
#[wasm_bindgen(js_name=getUserFeeIncrease)]
|
|
171
|
+
pub fn get_user_fee_increase(&self) -> u16 {
|
|
172
|
+
self.0.user_fee_increase() as u16
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
#[wasm_bindgen(js_name=setUserFeeIncrease)]
|
|
176
|
+
pub fn set_user_fee_increase(&mut self, user_fee_increase: u16) {
|
|
177
|
+
self.0.set_user_fee_increase(user_fee_increase);
|
|
178
|
+
}
|
|
179
|
+
|
|
170
180
|
#[wasm_bindgen(js_name=toObject)]
|
|
171
181
|
pub fn to_object(&self, options: JsValue) -> Result<JsValue, JsValue> {
|
|
172
182
|
let opts: super::to_object::ToObjectOptions = if options.is_object() {
|
|
@@ -90,13 +90,33 @@ impl IdentityCreditTransferTransitionWasm {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
#[wasm_bindgen(js_name=getAmount)]
|
|
93
|
-
pub fn get_amount(&self) ->
|
|
94
|
-
self.0.amount()
|
|
93
|
+
pub fn get_amount(&self) -> u64 {
|
|
94
|
+
self.0.amount()
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
#[wasm_bindgen(js_name=setAmount)]
|
|
98
|
-
pub fn set_amount(&mut self, amount:
|
|
99
|
-
self.0.set_amount(amount
|
|
98
|
+
pub fn set_amount(&mut self, amount: u64) {
|
|
99
|
+
self.0.set_amount(amount);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
#[wasm_bindgen(js_name=getUserFeeIncrease)]
|
|
103
|
+
pub fn get_user_fee_increase(&self) -> u16 {
|
|
104
|
+
self.0.user_fee_increase()
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
#[wasm_bindgen(js_name=setUserFeeIncrease)]
|
|
108
|
+
pub fn set_user_fee_increase(&mut self, user_fee_increase: u16) {
|
|
109
|
+
self.0.set_user_fee_increase(user_fee_increase);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
#[wasm_bindgen(js_name=getNonce)]
|
|
113
|
+
pub fn get_nonce(&self) -> u64 {
|
|
114
|
+
self.0.nonce()
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
#[wasm_bindgen(js_name=setNonce)]
|
|
118
|
+
pub fn set_nonce(&mut self, nonce: u64) {
|
|
119
|
+
self.0.set_nonce(nonce)
|
|
100
120
|
}
|
|
101
121
|
|
|
102
122
|
#[wasm_bindgen(js_name=toObject)]
|
|
@@ -161,7 +181,7 @@ impl IdentityCreditTransferTransitionWasm {
|
|
|
161
181
|
js_sys::Reflect::set(
|
|
162
182
|
&js_object,
|
|
163
183
|
&"amount".to_owned().into(),
|
|
164
|
-
&JsValue::
|
|
184
|
+
&JsValue::bigint_from_str(&object.amount.to_string()),
|
|
165
185
|
)?;
|
|
166
186
|
|
|
167
187
|
Ok(js_object.into())
|
|
@@ -236,7 +256,7 @@ impl IdentityCreditTransferTransitionWasm {
|
|
|
236
256
|
js_sys::Reflect::set(
|
|
237
257
|
&js_object,
|
|
238
258
|
&"amount".to_owned().into(),
|
|
239
|
-
&JsValue::
|
|
259
|
+
&JsValue::bigint_from_str(&object.amount.to_string()),
|
|
240
260
|
)?;
|
|
241
261
|
|
|
242
262
|
Ok(js_object.into())
|
|
@@ -318,6 +338,11 @@ impl IdentityCreditTransferTransitionWasm {
|
|
|
318
338
|
.set_signature(BinaryData::new(signature.unwrap_or_default()))
|
|
319
339
|
}
|
|
320
340
|
|
|
341
|
+
#[wasm_bindgen(js_name=getSignaturePublicKeyId)]
|
|
342
|
+
pub fn get_signature_public_key_id(&self) -> u32 {
|
|
343
|
+
self.0.signature_public_key_id()
|
|
344
|
+
}
|
|
345
|
+
|
|
321
346
|
#[wasm_bindgen]
|
|
322
347
|
pub fn sign(
|
|
323
348
|
&mut self,
|
|
@@ -136,6 +136,16 @@ impl IdentityCreditWithdrawalTransitionWasm {
|
|
|
136
136
|
self.0.set_nonce(revision);
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
#[wasm_bindgen(js_name=getUserFeeIncrease)]
|
|
140
|
+
pub fn get_user_fee_increase(&self) -> u16 {
|
|
141
|
+
self.0.user_fee_increase() as u16
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
#[wasm_bindgen(js_name=setUserFeeIncrease)]
|
|
145
|
+
pub fn set_user_fee_increase(&mut self, user_fee_increase: u16) {
|
|
146
|
+
self.0.set_user_fee_increase(user_fee_increase);
|
|
147
|
+
}
|
|
148
|
+
|
|
139
149
|
#[wasm_bindgen(js_name=toObject)]
|
|
140
150
|
pub fn to_object(&self, options: JsValue) -> Result<JsValue, JsValue> {
|
|
141
151
|
let opts: super::to_object::ToObjectOptions = if options.is_object() {
|
|
@@ -400,6 +410,11 @@ impl IdentityCreditWithdrawalTransitionWasm {
|
|
|
400
410
|
.set_signature(BinaryData::new(signature.unwrap_or_default()))
|
|
401
411
|
}
|
|
402
412
|
|
|
413
|
+
#[wasm_bindgen(js_name=getSignaturePublicKeyId)]
|
|
414
|
+
pub fn get_signature_public_key_id(&self) -> u32 {
|
|
415
|
+
self.0.signature_public_key_id()
|
|
416
|
+
}
|
|
417
|
+
|
|
403
418
|
#[wasm_bindgen]
|
|
404
419
|
pub fn sign(
|
|
405
420
|
&mut self,
|
package/src/identity/state_transition/identity_topup_transition/identity_topup_transition.rs
CHANGED
|
@@ -115,6 +115,16 @@ impl IdentityTopUpTransitionWasm {
|
|
|
115
115
|
self.0.owner_id().to_owned().into()
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
#[wasm_bindgen(js_name=getUserFeeIncrease)]
|
|
119
|
+
pub fn get_user_fee_increase(&self) -> u16 {
|
|
120
|
+
self.0.user_fee_increase() as u16
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
#[wasm_bindgen(js_name=setUserFeeIncrease)]
|
|
124
|
+
pub fn set_user_fee_increase(&mut self, user_fee_increase: u16) {
|
|
125
|
+
self.0.set_user_fee_increase(user_fee_increase);
|
|
126
|
+
}
|
|
127
|
+
|
|
118
128
|
#[wasm_bindgen(js_name=toObject)]
|
|
119
129
|
pub fn to_object(&self, options: JsValue) -> Result<JsValue, JsValue> {
|
|
120
130
|
let opts: super::to_object::ToObjectOptions = if options.is_object() {
|
package/src/identity/state_transition/identity_update_transition/identity_update_transition.rs
CHANGED
|
@@ -160,6 +160,26 @@ impl IdentityUpdateTransitionWasm {
|
|
|
160
160
|
StateTransitionLike::owner_id(&self.0).to_owned().into()
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
+
#[wasm_bindgen(js_name=getUserFeeIncrease)]
|
|
164
|
+
pub fn get_user_fee_increase(&self) -> u16 {
|
|
165
|
+
self.0.user_fee_increase()
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
#[wasm_bindgen(js_name=setUserFeeIncrease)]
|
|
169
|
+
pub fn set_user_fee_increase(&mut self, user_fee_increase: u16) {
|
|
170
|
+
self.0.set_user_fee_increase(user_fee_increase);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
#[wasm_bindgen(js_name=getIdentityContractNonce)]
|
|
174
|
+
pub fn get_identity_nonce(&self) -> u64 {
|
|
175
|
+
self.0.nonce()
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
#[wasm_bindgen(js_name=setIdentityContractNonce)]
|
|
179
|
+
pub fn set_identity_contract_nonce(&mut self, identity_nonce: u64) {
|
|
180
|
+
self.0.set_nonce(identity_nonce)
|
|
181
|
+
}
|
|
182
|
+
|
|
163
183
|
#[wasm_bindgen(js_name=toObject)]
|
|
164
184
|
pub fn to_object(&self, options: JsValue) -> Result<JsValue, JsValue> {
|
|
165
185
|
let opts: super::to_object::ToObjectOptions = if options.is_object() {
|
|
@@ -403,6 +423,11 @@ impl IdentityUpdateTransitionWasm {
|
|
|
403
423
|
Buffer::from_bytes_owned(self.0.signature().to_vec())
|
|
404
424
|
}
|
|
405
425
|
|
|
426
|
+
#[wasm_bindgen(js_name=getSignaturePublicKeyId)]
|
|
427
|
+
pub fn get_signature_public_key_id(&self) -> u32 {
|
|
428
|
+
self.0.signature_public_key_id()
|
|
429
|
+
}
|
|
430
|
+
|
|
406
431
|
#[wasm_bindgen(js_name=setSignature)]
|
|
407
432
|
pub fn set_signature(&mut self, signature: Option<Vec<u8>>) {
|
|
408
433
|
self.0
|
|
@@ -410,13 +435,13 @@ impl IdentityUpdateTransitionWasm {
|
|
|
410
435
|
}
|
|
411
436
|
|
|
412
437
|
#[wasm_bindgen(js_name=getRevision)]
|
|
413
|
-
pub fn get_revision(&self) ->
|
|
414
|
-
self.0.revision()
|
|
438
|
+
pub fn get_revision(&self) -> u64 {
|
|
439
|
+
self.0.revision()
|
|
415
440
|
}
|
|
416
441
|
|
|
417
442
|
#[wasm_bindgen(js_name=setRevision)]
|
|
418
|
-
pub fn set_revision(&mut self, revision:
|
|
419
|
-
self.0.set_revision(revision
|
|
443
|
+
pub fn set_revision(&mut self, revision: u64) {
|
|
444
|
+
self.0.set_revision(revision)
|
|
420
445
|
}
|
|
421
446
|
|
|
422
447
|
#[wasm_bindgen]
|
|
@@ -16,7 +16,7 @@ pub struct ToObjectOptions {
|
|
|
16
16
|
#[derive(Default)]
|
|
17
17
|
pub struct ToObject {
|
|
18
18
|
pub transition_type: u8,
|
|
19
|
-
pub revision:
|
|
19
|
+
pub revision: u64,
|
|
20
20
|
pub signature: Option<Vec<u8>>,
|
|
21
21
|
pub signature_public_key_id: KeyID,
|
|
22
22
|
pub public_keys_to_add: Option<Vec<IdentityPublicKeyInCreation>>,
|
|
@@ -30,7 +30,7 @@ pub fn to_object_struct(
|
|
|
30
30
|
) -> ToObject {
|
|
31
31
|
let mut to_object = ToObject {
|
|
32
32
|
transition_type: transition.state_transition_type() as u8,
|
|
33
|
-
revision: transition.revision()
|
|
33
|
+
revision: transition.revision(),
|
|
34
34
|
identity_id: transition.identity_id().to_owned(),
|
|
35
35
|
..ToObject::default()
|
|
36
36
|
};
|
|
@@ -19,7 +19,7 @@ impl From<StateTransitionType> for StateTransitionTypeWasm {
|
|
|
19
19
|
fn from(state_transition_type: StateTransitionType) -> Self {
|
|
20
20
|
match state_transition_type {
|
|
21
21
|
StateTransitionType::DataContractCreate => StateTransitionTypeWasm::DataContractCreate,
|
|
22
|
-
StateTransitionType::
|
|
22
|
+
StateTransitionType::Batch => StateTransitionTypeWasm::DocumentsBatch,
|
|
23
23
|
StateTransitionType::IdentityCreate => StateTransitionTypeWasm::IdentityCreate,
|
|
24
24
|
StateTransitionType::IdentityTopUp => StateTransitionTypeWasm::IdentityTopUp,
|
|
25
25
|
StateTransitionType::DataContractUpdate => StateTransitionTypeWasm::DataContractUpdate,
|
package/src/metadata.rs
CHANGED
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
pub use serde::Serialize;
|
|
4
4
|
use wasm_bindgen::prelude::*;
|
|
5
5
|
|
|
6
|
-
use crate::utils::ToSerdeJSONExt;
|
|
7
6
|
use dpp::metadata::Metadata;
|
|
8
7
|
use dpp::util::deserializer::ProtocolVersion;
|
|
9
|
-
use dpp::util::json_value::JsonValueExt;
|
|
10
8
|
|
|
11
9
|
#[wasm_bindgen(js_name=Metadata)]
|
|
12
10
|
#[derive(Clone, Debug)]
|
|
@@ -34,25 +32,16 @@ impl Into<Metadata> for MetadataWasm {
|
|
|
34
32
|
#[wasm_bindgen(js_class=Metadata)]
|
|
35
33
|
impl MetadataWasm {
|
|
36
34
|
#[wasm_bindgen(constructor)]
|
|
37
|
-
pub fn new(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
.get_f64("coreChainLockedHeight")
|
|
44
|
-
.map_err(|e| JsError::new(&e.to_string()))?;
|
|
45
|
-
let time_ms = metadata_options
|
|
46
|
-
.get_f64("timeMs")
|
|
47
|
-
.map_err(|e| JsError::new(&e.to_string()))?;
|
|
48
|
-
let protocol_version = metadata_options
|
|
49
|
-
.get_f64("protocolVersion")
|
|
50
|
-
.map_err(|e| JsError::new(&e.to_string()))?;
|
|
51
|
-
|
|
35
|
+
pub fn new(
|
|
36
|
+
block_height: u64,
|
|
37
|
+
core_chain_locked_height: u32,
|
|
38
|
+
time_ms: u64,
|
|
39
|
+
protocol_version: u32,
|
|
40
|
+
) -> Result<MetadataWasm, JsValue> {
|
|
52
41
|
let inner = Metadata {
|
|
53
|
-
block_height
|
|
42
|
+
block_height,
|
|
54
43
|
core_chain_locked_height: core_chain_locked_height as u64,
|
|
55
|
-
time_ms
|
|
44
|
+
time_ms,
|
|
56
45
|
protocol_version: protocol_version as u64 as ProtocolVersion,
|
|
57
46
|
};
|
|
58
47
|
Ok(inner.into())
|
|
@@ -77,22 +66,22 @@ impl MetadataWasm {
|
|
|
77
66
|
}
|
|
78
67
|
|
|
79
68
|
#[wasm_bindgen(js_name=getBlockHeight)]
|
|
80
|
-
pub fn block_height(&self) ->
|
|
81
|
-
self.0.block_height
|
|
69
|
+
pub fn block_height(&self) -> u64 {
|
|
70
|
+
self.0.block_height
|
|
82
71
|
}
|
|
83
72
|
|
|
84
73
|
#[wasm_bindgen(js_name=getCoreChainLockedHeight)]
|
|
85
|
-
pub fn core_chain_locked_height(&self) ->
|
|
86
|
-
self.0.core_chain_locked_height as
|
|
74
|
+
pub fn core_chain_locked_height(&self) -> u32 {
|
|
75
|
+
self.0.core_chain_locked_height as u32
|
|
87
76
|
}
|
|
88
77
|
|
|
89
78
|
#[wasm_bindgen(js_name=getTimeMs)]
|
|
90
|
-
pub fn time_ms(&self) ->
|
|
91
|
-
self.0.time_ms
|
|
79
|
+
pub fn time_ms(&self) -> u64 {
|
|
80
|
+
self.0.time_ms
|
|
92
81
|
}
|
|
93
82
|
|
|
94
83
|
#[wasm_bindgen(js_name=getProtocolVersion)]
|
|
95
|
-
pub fn protocol_version(&self) ->
|
|
96
|
-
self.0.protocol_version
|
|
84
|
+
pub fn protocol_version(&self) -> u32 {
|
|
85
|
+
self.0.protocol_version
|
|
97
86
|
}
|
|
98
87
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
use crate::batch_transition::BatchTransitionWasm;
|
|
1
2
|
use crate::data_contract::{DataContractCreateTransitionWasm, DataContractUpdateTransitionWasm};
|
|
2
|
-
use crate::document_batch_transition::DocumentsBatchTransitionWasm;
|
|
3
3
|
use crate::errors::from_dpp_err;
|
|
4
4
|
use crate::identity::state_transition::{
|
|
5
5
|
IdentityCreateTransitionWasm, IdentityCreditTransferTransitionWasm,
|
|
@@ -56,9 +56,7 @@ impl StateTransitionFactoryWasm {
|
|
|
56
56
|
StateTransition::IdentityCreditWithdrawal(st) => {
|
|
57
57
|
Ok(IdentityCreditWithdrawalTransitionWasm::from(st).into())
|
|
58
58
|
}
|
|
59
|
-
StateTransition::
|
|
60
|
-
Ok(DocumentsBatchTransitionWasm::from(st).into())
|
|
61
|
-
}
|
|
59
|
+
StateTransition::Batch(st) => Ok(BatchTransitionWasm::from(st).into()),
|
|
62
60
|
StateTransition::MasternodeVote(st) => {
|
|
63
61
|
Ok(MasternodeVoteTransitionWasm::from(st).into())
|
|
64
62
|
}
|