@dashevo/wasm-dpp 2.0.0-rc.8 → 2.0.0
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/Cargo.toml +1 -1
- package/dist/wasm/wasm_dpp.d.ts +1192 -1033
- package/dist/wasm/wasm_dpp.js +175 -69
- package/dist/wasm/wasm_dpp_bg.js +1 -1
- package/lib/wasm/wasm_dpp.d.ts +1192 -1033
- package/package.json +3 -3
- package/src/data_contract/data_contract.rs +2 -3
- package/src/data_contract/state_transition/data_contract_create_transition/mod.rs +18 -3
- package/src/data_contract/state_transition/data_contract_update_transition/mod.rs +18 -3
- package/src/document/state_transition/batch_transition/token_transition/burn.rs +14 -0
- package/src/document/state_transition/batch_transition/token_transition/claim.rs +18 -0
- package/src/document/state_transition/batch_transition/token_transition/config.rs +9 -0
- package/src/document/state_transition/batch_transition/token_transition/destroy.rs +5 -0
- package/src/document/state_transition/batch_transition/token_transition/direct_purchase.rs +16 -0
- package/src/document/state_transition/batch_transition/token_transition/emergency_action.rs +18 -0
- package/src/document/state_transition/batch_transition/token_transition/freeze.rs +5 -0
- package/src/document/state_transition/batch_transition/token_transition/mint.rs +15 -0
- package/src/document/state_transition/batch_transition/token_transition/set_price_for_direct_purchase.rs +22 -0
- package/src/document/state_transition/batch_transition/token_transition/transfer.rs +10 -0
- package/src/document/state_transition/batch_transition/token_transition/unfreeze.rs +5 -0
- package/src/errors/consensus/consensus_error.rs +42 -5
- package/test/unit/dataContract/stateTransition/DataContractCreateTransition/DataContractCreateTransition.spec.js +7 -1
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/DataContractUpdateTransition.spec.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashevo/wasm-dpp",
|
|
3
|
-
"version": "2.0.0
|
|
3
|
+
"version": "2.0.0",
|
|
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": "2.0.0
|
|
47
|
+
"@dashevo/dpns-contract": "2.0.0",
|
|
48
48
|
"@types/bs58": "^4.0.1",
|
|
49
49
|
"@types/node": "^14.6.0",
|
|
50
50
|
"@yarnpkg/pnpify": "^4.0.0-rc.42",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"chai-as-promised": "^7.1.1",
|
|
56
56
|
"chai-exclude": "^2.1.0",
|
|
57
57
|
"chai-string": "^1.5.0",
|
|
58
|
-
"crypto-browserify": "^3.12.
|
|
58
|
+
"crypto-browserify": "^3.12.1",
|
|
59
59
|
"dirty-chai": "^2.0.1",
|
|
60
60
|
"eslint": "^8.53.0",
|
|
61
61
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
@@ -415,12 +415,11 @@ impl DataContractWasm {
|
|
|
415
415
|
self.clone()
|
|
416
416
|
}
|
|
417
417
|
|
|
418
|
-
pub(crate) fn
|
|
418
|
+
pub(crate) fn try_from_serialization_format_with_platform_version(
|
|
419
419
|
value: DataContractInSerializationFormat,
|
|
420
420
|
full_validation: bool,
|
|
421
|
+
platform_version: &PlatformVersion,
|
|
421
422
|
) -> Result<Self, JsValue> {
|
|
422
|
-
let platform_version = PlatformVersion::first();
|
|
423
|
-
|
|
424
423
|
DataContract::try_from_platform_versioned(
|
|
425
424
|
value,
|
|
426
425
|
full_validation,
|
|
@@ -55,9 +55,24 @@ impl DataContractCreateTransitionWasm {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
#[wasm_bindgen(js_name=getDataContract)]
|
|
58
|
-
pub fn get_data_contract(
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
pub fn get_data_contract(
|
|
59
|
+
&self,
|
|
60
|
+
protocol_version: Option<u32>,
|
|
61
|
+
) -> Result<DataContractWasm, JsValue> {
|
|
62
|
+
// Use provided protocol version or latest if not specified
|
|
63
|
+
let platform_version = if let Some(version) = protocol_version {
|
|
64
|
+
PlatformVersion::get(version)
|
|
65
|
+
.map_err(ProtocolError::PlatformVersionError)
|
|
66
|
+
.with_js_error()?
|
|
67
|
+
} else {
|
|
68
|
+
PlatformVersion::latest()
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
DataContractWasm::try_from_serialization_format_with_platform_version(
|
|
72
|
+
self.0.data_contract().clone(),
|
|
73
|
+
false,
|
|
74
|
+
platform_version,
|
|
75
|
+
)
|
|
61
76
|
}
|
|
62
77
|
|
|
63
78
|
// #[wasm_bindgen(js_name=setDataContractConfig)]
|
|
@@ -56,9 +56,24 @@ impl DataContractUpdateTransitionWasm {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
#[wasm_bindgen(js_name=getDataContract)]
|
|
59
|
-
pub fn get_data_contract(
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
pub fn get_data_contract(
|
|
60
|
+
&self,
|
|
61
|
+
protocol_version: Option<u32>,
|
|
62
|
+
) -> Result<DataContractWasm, JsValue> {
|
|
63
|
+
// Use provided protocol version or latest if not specified
|
|
64
|
+
let platform_version = if let Some(version) = protocol_version {
|
|
65
|
+
PlatformVersion::get(version)
|
|
66
|
+
.map_err(ProtocolError::PlatformVersionError)
|
|
67
|
+
.with_js_error()?
|
|
68
|
+
} else {
|
|
69
|
+
PlatformVersion::latest()
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
DataContractWasm::try_from_serialization_format_with_platform_version(
|
|
73
|
+
self.0.data_contract().clone(),
|
|
74
|
+
false,
|
|
75
|
+
platform_version,
|
|
76
|
+
)
|
|
62
77
|
}
|
|
63
78
|
|
|
64
79
|
// #[wasm_bindgen(js_name=setDataContractConfig)]
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
use dpp::state_transition::batch_transition::token_burn_transition::v0::v0_methods::TokenBurnTransitionV0Methods;
|
|
1
2
|
use dpp::state_transition::batch_transition::TokenBurnTransition;
|
|
2
3
|
use wasm_bindgen::prelude::wasm_bindgen;
|
|
3
4
|
|
|
@@ -10,3 +11,16 @@ impl From<TokenBurnTransition> for TokenBurnTransitionWasm {
|
|
|
10
11
|
Self(value)
|
|
11
12
|
}
|
|
12
13
|
}
|
|
14
|
+
|
|
15
|
+
#[wasm_bindgen(js_class = TokenBurnTransition)]
|
|
16
|
+
impl TokenBurnTransitionWasm {
|
|
17
|
+
#[wasm_bindgen(js_name=getPublicNote)]
|
|
18
|
+
pub fn public_note(&self) -> Option<String> {
|
|
19
|
+
self.0.public_note().cloned()
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
#[wasm_bindgen(js_name=getBurnAmount)]
|
|
23
|
+
pub fn amount(&self) -> u64 {
|
|
24
|
+
self.0.burn_amount()
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
use dpp::data_contract::associated_token::token_distribution_key::TokenDistributionType;
|
|
2
|
+
use dpp::state_transition::batch_transition::token_claim_transition::v0::v0_methods::TokenClaimTransitionV0Methods;
|
|
1
3
|
use dpp::state_transition::batch_transition::TokenClaimTransition;
|
|
2
4
|
use wasm_bindgen::prelude::wasm_bindgen;
|
|
3
5
|
|
|
@@ -10,3 +12,19 @@ impl From<TokenClaimTransition> for TokenClaimTransitionWasm {
|
|
|
10
12
|
Self(value)
|
|
11
13
|
}
|
|
12
14
|
}
|
|
15
|
+
|
|
16
|
+
#[wasm_bindgen(js_class = TokenClaimTransition)]
|
|
17
|
+
impl TokenClaimTransitionWasm {
|
|
18
|
+
#[wasm_bindgen(js_name=getPublicNote)]
|
|
19
|
+
pub fn public_note(&self) -> Option<String> {
|
|
20
|
+
self.0.public_note().cloned()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
#[wasm_bindgen(js_name=getDistributionType)]
|
|
24
|
+
pub fn distribution_type(&self) -> u8 {
|
|
25
|
+
match self.0.distribution_type() {
|
|
26
|
+
TokenDistributionType::PreProgrammed => 0,
|
|
27
|
+
TokenDistributionType::Perpetual => 1,
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
use dpp::state_transition::batch_transition::token_config_update_transition::v0::v0_methods::TokenConfigUpdateTransitionV0Methods;
|
|
1
2
|
use dpp::state_transition::batch_transition::TokenConfigUpdateTransition;
|
|
2
3
|
use wasm_bindgen::prelude::wasm_bindgen;
|
|
3
4
|
|
|
@@ -10,3 +11,11 @@ impl From<TokenConfigUpdateTransition> for TokenConfigUpdateTransitionWasm {
|
|
|
10
11
|
Self(value)
|
|
11
12
|
}
|
|
12
13
|
}
|
|
14
|
+
|
|
15
|
+
#[wasm_bindgen(js_class = TokenConfigUpdateTransition)]
|
|
16
|
+
impl TokenConfigUpdateTransitionWasm {
|
|
17
|
+
#[wasm_bindgen(js_name=getPublicNote)]
|
|
18
|
+
pub fn public_note(&self) -> Option<String> {
|
|
19
|
+
self.0.public_note().cloned()
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -19,4 +19,9 @@ impl TokenDestroyFrozenFundsTransitionWasm {
|
|
|
19
19
|
pub fn frozen_identity_id(&self) -> IdentifierWrapper {
|
|
20
20
|
self.0.frozen_identity_id().into()
|
|
21
21
|
}
|
|
22
|
+
|
|
23
|
+
#[wasm_bindgen(js_name=getPublicNote)]
|
|
24
|
+
pub fn public_note(&self) -> Option<String> {
|
|
25
|
+
self.0.public_note().cloned()
|
|
26
|
+
}
|
|
22
27
|
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
use dpp::balances::credits::TokenAmount;
|
|
2
|
+
use dpp::fee::Credits;
|
|
3
|
+
use dpp::state_transition::batch_transition::token_direct_purchase_transition::v0::v0_methods::TokenDirectPurchaseTransitionV0Methods;
|
|
1
4
|
use dpp::state_transition::batch_transition::TokenDirectPurchaseTransition;
|
|
2
5
|
use wasm_bindgen::prelude::wasm_bindgen;
|
|
3
6
|
|
|
@@ -10,3 +13,16 @@ impl From<TokenDirectPurchaseTransition> for TokenDirectPurchaseTransitionWasm {
|
|
|
10
13
|
Self(value)
|
|
11
14
|
}
|
|
12
15
|
}
|
|
16
|
+
|
|
17
|
+
#[wasm_bindgen(js_class = TokenDirectPurchaseTransition)]
|
|
18
|
+
impl TokenDirectPurchaseTransitionWasm {
|
|
19
|
+
#[wasm_bindgen(js_name=getTokenCount)]
|
|
20
|
+
pub fn count(&self) -> TokenAmount {
|
|
21
|
+
self.0.token_count()
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
#[wasm_bindgen(js_name=getTotalAgreedPrice)]
|
|
25
|
+
pub fn total_agreed_price(&self) -> Credits {
|
|
26
|
+
self.0.total_agreed_price()
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
use dpp::state_transition::batch_transition::token_emergency_action_transition::v0::v0_methods::TokenEmergencyActionTransitionV0Methods;
|
|
1
2
|
use dpp::state_transition::batch_transition::TokenEmergencyActionTransition;
|
|
3
|
+
use dpp::tokens::emergency_action::TokenEmergencyAction;
|
|
2
4
|
use wasm_bindgen::prelude::wasm_bindgen;
|
|
3
5
|
|
|
4
6
|
#[wasm_bindgen(js_name=TokenEmergencyActionTransition)]
|
|
@@ -10,3 +12,19 @@ impl From<TokenEmergencyActionTransition> for TokenEmergencyActionTransitionWasm
|
|
|
10
12
|
Self(value)
|
|
11
13
|
}
|
|
12
14
|
}
|
|
15
|
+
|
|
16
|
+
#[wasm_bindgen(js_class = TokenEmergencyActionTransition)]
|
|
17
|
+
impl TokenEmergencyActionTransitionWasm {
|
|
18
|
+
#[wasm_bindgen(js_name=getPublicNote)]
|
|
19
|
+
pub fn public_note(&self) -> Option<String> {
|
|
20
|
+
self.0.public_note().cloned()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
#[wasm_bindgen(js_name=getEmergencyAction)]
|
|
24
|
+
pub fn emergency_action(&self) -> u8 {
|
|
25
|
+
match self.0.emergency_action() {
|
|
26
|
+
TokenEmergencyAction::Pause => 0,
|
|
27
|
+
TokenEmergencyAction::Resume => 1,
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -19,4 +19,9 @@ impl TokenFreezeTransitionWasm {
|
|
|
19
19
|
pub fn frozen_identity_id(&self) -> IdentifierWrapper {
|
|
20
20
|
self.0.frozen_identity_id().into()
|
|
21
21
|
}
|
|
22
|
+
|
|
23
|
+
#[wasm_bindgen(js_name=getPublicNote)]
|
|
24
|
+
pub fn public_note(&self) -> Option<String> {
|
|
25
|
+
self.0.public_note().cloned()
|
|
26
|
+
}
|
|
22
27
|
}
|
|
@@ -28,4 +28,19 @@ impl TokenMintTransitionWasm {
|
|
|
28
28
|
.with_js_error()
|
|
29
29
|
.map(Into::into)
|
|
30
30
|
}
|
|
31
|
+
|
|
32
|
+
#[wasm_bindgen(js_name=getIssuedToIdentityId)]
|
|
33
|
+
pub fn issued_to_identity_id(&self) -> Option<IdentifierWrapper> {
|
|
34
|
+
self.0.issued_to_identity_id().map(|id| id.into())
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
#[wasm_bindgen(js_name=getPublicNote)]
|
|
38
|
+
pub fn public_note(&self) -> Option<String> {
|
|
39
|
+
self.0.public_note().cloned()
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
#[wasm_bindgen(js_name=getAmount)]
|
|
43
|
+
pub fn amount(&self) -> u64 {
|
|
44
|
+
self.0.amount()
|
|
45
|
+
}
|
|
31
46
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
use dpp::state_transition::batch_transition::TokenSetPriceForDirectPurchaseTransition;
|
|
2
2
|
use wasm_bindgen::prelude::wasm_bindgen;
|
|
3
|
+
use dpp::fee::Credits;
|
|
4
|
+
use dpp::state_transition::batch_transition::token_set_price_for_direct_purchase_transition::v0::v0_methods::TokenSetPriceForDirectPurchaseTransitionV0Methods;
|
|
5
|
+
use dpp::tokens::token_pricing_schedule::TokenPricingSchedule;
|
|
3
6
|
|
|
4
7
|
#[wasm_bindgen(js_name=TokenSetPriceForDirectPurchaseTransition)]
|
|
5
8
|
#[derive(Debug, Clone)]
|
|
@@ -12,3 +15,22 @@ impl From<TokenSetPriceForDirectPurchaseTransition>
|
|
|
12
15
|
Self(value)
|
|
13
16
|
}
|
|
14
17
|
}
|
|
18
|
+
|
|
19
|
+
#[wasm_bindgen(js_class=TokenSetPriceForDirectPurchaseTransition)]
|
|
20
|
+
impl TokenSetPriceForDirectPurchaseTransitionWasm {
|
|
21
|
+
#[wasm_bindgen(js_name=getPublicNote)]
|
|
22
|
+
pub fn public_note(&self) -> Option<String> {
|
|
23
|
+
self.0.public_note().cloned()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
#[wasm_bindgen(js_name=getPrice)]
|
|
27
|
+
pub fn price(&self) -> Option<Credits> {
|
|
28
|
+
match self.0.price() {
|
|
29
|
+
Some(token_pricing_schedule) => match token_pricing_schedule {
|
|
30
|
+
TokenPricingSchedule::SinglePrice(credits) => Some(*credits),
|
|
31
|
+
TokenPricingSchedule::SetPrices(_) => None,
|
|
32
|
+
},
|
|
33
|
+
None => None,
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -19,4 +19,14 @@ impl TokenTransferTransitionWasm {
|
|
|
19
19
|
pub fn recipient_id(&self) -> IdentifierWrapper {
|
|
20
20
|
self.0.recipient_id().into()
|
|
21
21
|
}
|
|
22
|
+
|
|
23
|
+
#[wasm_bindgen(js_name=getPublicNote)]
|
|
24
|
+
pub fn public_note(&self) -> Option<String> {
|
|
25
|
+
self.0.public_note().cloned()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
#[wasm_bindgen(js_name=getAmount)]
|
|
29
|
+
pub fn amount(&self) -> u64 {
|
|
30
|
+
self.0.amount()
|
|
31
|
+
}
|
|
22
32
|
}
|
|
@@ -19,4 +19,9 @@ impl TokenUnfreezeTransitionWasm {
|
|
|
19
19
|
pub fn frozen_identity_id(&self) -> IdentifierWrapper {
|
|
20
20
|
self.0.frozen_identity_id().into()
|
|
21
21
|
}
|
|
22
|
+
|
|
23
|
+
#[wasm_bindgen(js_name=getPublicNote)]
|
|
24
|
+
pub fn public_note(&self) -> Option<String> {
|
|
25
|
+
self.0.public_note().cloned()
|
|
26
|
+
}
|
|
22
27
|
}
|
|
@@ -61,12 +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, DataContractTokenConfigurationUpdateError, DecimalsOverLimitError, DuplicateKeywordsError, GroupExceedsMaxMembersError, GroupMemberHasPowerOfZeroError, GroupMemberHasPowerOverLimitError, GroupNonUnilateralMemberPowerHasLessThanRequiredPowerError, GroupPositionDoesNotExistError, GroupRequiredPowerIsInvalidError, GroupTotalPowerLessThanRequiredError, InvalidDescriptionLengthError, InvalidDocumentTypeRequiredSecurityLevelError, InvalidKeywordCharacterError, InvalidKeywordLengthError, InvalidTokenBaseSupplyError, InvalidTokenDistributionFunctionDivideByZeroError, InvalidTokenDistributionFunctionIncoherenceError, InvalidTokenDistributionFunctionInvalidParameterError, InvalidTokenDistributionFunctionInvalidParameterTupleError, InvalidTokenLanguageCodeError, InvalidTokenNameCharacterError, InvalidTokenNameLengthError, MainGroupIsNotDefinedError, NewTokensDestinationIdentityOptionRequiredError, NonContiguousContractGroupPositionsError, NonContiguousContractTokenPositionsError, TokenPaymentByBurningOnlyAllowedOnInternalTokenError, TooManyKeywordsError, UnknownDocumentActionTokenEffectError, UnknownDocumentCreationRestrictionModeError, UnknownGasFeesPaidByError, UnknownSecurityLevelError, UnknownStorageKeyRequirementsError, UnknownTradeModeError, UnknownTransferableTypeError};
|
|
64
|
+
use dpp::consensus::basic::data_contract::{ContestedUniqueIndexOnMutableDocumentTypeError, 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, RedundantDocumentPaidForByTokenWithContractId, TokenPaymentByBurningOnlyAllowedOnInternalTokenError, TooManyKeywordsError, UnknownDocumentActionTokenEffectError, UnknownDocumentCreationRestrictionModeError, UnknownGasFeesPaidByError, UnknownSecurityLevelError, UnknownStorageKeyRequirementsError, UnknownTradeModeError, UnknownTransferableTypeError};
|
|
65
65
|
use dpp::consensus::basic::document::{ContestedDocumentsTemporarilyNotAllowedError, DocumentCreationNotAllowedError, DocumentFieldMaxSizeExceededError, MaxDocumentsTransitionsExceededError, MissingPositionsInDocumentTypePropertiesError};
|
|
66
66
|
use dpp::consensus::basic::group::GroupActionNotAllowedOnTransitionError;
|
|
67
|
-
use dpp::consensus::basic::identity::{DataContractBoundsNotPresentError, DisablingKeyIdAlsoBeingAddedInSameTransitionError, InvalidIdentityCreditWithdrawalTransitionAmountError, InvalidIdentityUpdateTransitionDisableKeysError, InvalidIdentityUpdateTransitionEmptyError, TooManyMasterPublicKeyError, WithdrawalOutputScriptNotAllowedWhenSigningWithOwnerKeyError};
|
|
67
|
+
use dpp::consensus::basic::identity::{DataContractBoundsNotPresentError, DisablingKeyIdAlsoBeingAddedInSameTransitionError, InvalidIdentityCreditWithdrawalTransitionAmountError, InvalidIdentityUpdateTransitionDisableKeysError, InvalidIdentityUpdateTransitionEmptyError, InvalidKeyPurposeForContractBoundsError, TooManyMasterPublicKeyError, WithdrawalOutputScriptNotAllowedWhenSigningWithOwnerKeyError};
|
|
68
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};
|
|
69
|
+
use dpp::consensus::basic::token::{ChoosingTokenMintRecipientNotAllowedError, ContractHasNoTokensError, DestinationIdentityForTokenMintingNotSetError, InvalidActionIdError, InvalidTokenAmountError, InvalidTokenConfigUpdateNoChangeError, InvalidTokenIdError, InvalidTokenNoteTooBigError, InvalidTokenPositionError, MissingDefaultLocalizationError, TokenNoteOnlyAllowedWhenProposerError, TokenTransferToOurselfError, InvalidTokenDistributionTimeIntervalNotMinuteAlignedError, InvalidTokenDistributionTimeIntervalTooShortError, InvalidTokenDistributionBlockIntervalTooShortError};
|
|
70
|
+
use dpp::consensus::state::data_contract::data_contract_not_found_error::DataContractNotFoundError;
|
|
70
71
|
use dpp::consensus::state::data_contract::data_contract_update_action_not_allowed_error::DataContractUpdateActionNotAllowedError;
|
|
71
72
|
use dpp::consensus::state::data_contract::document_type_update_error::DocumentTypeUpdateError;
|
|
72
73
|
use dpp::consensus::state::document::document_contest_currently_locked_error::DocumentContestCurrentlyLockedError;
|
|
@@ -76,16 +77,17 @@ use dpp::consensus::state::document::document_contest_not_joinable_error::Docume
|
|
|
76
77
|
use dpp::consensus::state::document::document_contest_not_paid_for_error::DocumentContestNotPaidForError;
|
|
77
78
|
use dpp::consensus::state::document::document_incorrect_purchase_price_error::DocumentIncorrectPurchasePriceError;
|
|
78
79
|
use dpp::consensus::state::document::document_not_for_sale_error::DocumentNotForSaleError;
|
|
79
|
-
use dpp::consensus::state::group::{GroupActionAlreadyCompletedError, GroupActionAlreadySignedByIdentityError, GroupActionDoesNotExistError, IdentityMemberOfGroupNotFoundError, IdentityNotMemberOfGroupError};
|
|
80
|
+
use dpp::consensus::state::group::{GroupActionAlreadyCompletedError, GroupActionAlreadySignedByIdentityError, GroupActionDoesNotExistError, IdentityMemberOfGroupNotFoundError, IdentityNotMemberOfGroupError, ModificationOfGroupActionMainParametersNotPermittedError};
|
|
80
81
|
use dpp::consensus::state::identity::identity_for_token_configuration_not_found_error::IdentityInTokenConfigurationNotFoundError;
|
|
81
82
|
use dpp::consensus::state::identity::identity_public_key_already_exists_for_unique_contract_bounds_error::IdentityPublicKeyAlreadyExistsForUniqueContractBoundsError;
|
|
83
|
+
use dpp::consensus::state::identity::identity_to_freeze_does_not_exist_error::IdentityToFreezeDoesNotExistError;
|
|
82
84
|
use dpp::consensus::state::identity::master_public_key_update_error::MasterPublicKeyUpdateError;
|
|
83
85
|
use dpp::consensus::state::identity::missing_transfer_key_error::MissingTransferKeyError;
|
|
84
86
|
use dpp::consensus::state::identity::no_transfer_key_for_core_withdrawal_available_error::NoTransferKeyForCoreWithdrawalAvailableError;
|
|
85
87
|
use dpp::consensus::state::identity::RecipientIdentityDoesNotExistError;
|
|
86
88
|
use dpp::consensus::state::prefunded_specialized_balances::prefunded_specialized_balance_insufficient_error::PrefundedSpecializedBalanceInsufficientError;
|
|
87
89
|
use dpp::consensus::state::prefunded_specialized_balances::prefunded_specialized_balance_not_found_error::PrefundedSpecializedBalanceNotFoundError;
|
|
88
|
-
use dpp::consensus::state::token::{IdentityDoesNotHaveEnoughTokenBalanceError, IdentityTokenAccountNotFrozenError, IdentityTokenAccountFrozenError, TokenIsPausedError, IdentityTokenAccountAlreadyFrozenError, UnauthorizedTokenActionError, TokenSettingMaxSupplyToLessThanCurrentSupplyError, TokenMintPastMaxSupplyError, NewTokensDestinationIdentityDoesNotExistError, NewAuthorizedActionTakerIdentityDoesNotExistError, NewAuthorizedActionTakerGroupDoesNotExistError, NewAuthorizedActionTakerMainGroupNotSetError, InvalidGroupPositionError, TokenAlreadyPausedError, TokenNotPausedError, InvalidTokenClaimPropertyMismatch, InvalidTokenClaimNoCurrentRewards, InvalidTokenClaimWrongClaimant, TokenTransferRecipientIdentityNotExistError, PreProgrammedDistributionTimestampInPastError, IdentityHasNotAgreedToPayRequiredTokenAmountError, RequiredTokenPaymentInfoNotSetError, IdentityTryingToPayWithWrongTokenError, TokenDirectPurchaseUserPriceTooLow, TokenAmountUnderMinimumSaleAmount, TokenNotForDirectSale};
|
|
90
|
+
use dpp::consensus::state::token::{IdentityDoesNotHaveEnoughTokenBalanceError, IdentityTokenAccountNotFrozenError, IdentityTokenAccountFrozenError, TokenIsPausedError, IdentityTokenAccountAlreadyFrozenError, UnauthorizedTokenActionError, TokenSettingMaxSupplyToLessThanCurrentSupplyError, TokenMintPastMaxSupplyError, NewTokensDestinationIdentityDoesNotExistError, NewAuthorizedActionTakerIdentityDoesNotExistError, NewAuthorizedActionTakerGroupDoesNotExistError, NewAuthorizedActionTakerMainGroupNotSetError, InvalidGroupPositionError, TokenAlreadyPausedError, TokenNotPausedError, InvalidTokenClaimPropertyMismatch, InvalidTokenClaimNoCurrentRewards, InvalidTokenClaimWrongClaimant, TokenTransferRecipientIdentityNotExistError, PreProgrammedDistributionTimestampInPastError, IdentityHasNotAgreedToPayRequiredTokenAmountError, RequiredTokenPaymentInfoNotSetError, IdentityTryingToPayWithWrongTokenError, TokenDirectPurchaseUserPriceTooLow, TokenAmountUnderMinimumSaleAmount, TokenNotForDirectSale, InvalidTokenPositionStateError};
|
|
89
91
|
use dpp::consensus::state::voting::masternode_incorrect_voter_identity_id_error::MasternodeIncorrectVoterIdentityIdError;
|
|
90
92
|
use dpp::consensus::state::voting::masternode_incorrect_voting_address_error::MasternodeIncorrectVotingAddressError;
|
|
91
93
|
use dpp::consensus::state::voting::masternode_not_found_error::MasternodeNotFoundError;
|
|
@@ -415,6 +417,19 @@ pub fn from_state_error(state_error: &StateError) -> JsValue {
|
|
|
415
417
|
StateError::IdentityMemberOfGroupNotFoundError(e) => {
|
|
416
418
|
generic_consensus_error!(IdentityMemberOfGroupNotFoundError, e).into()
|
|
417
419
|
}
|
|
420
|
+
StateError::ModificationOfGroupActionMainParametersNotPermittedError(e) => {
|
|
421
|
+
generic_consensus_error!(ModificationOfGroupActionMainParametersNotPermittedError, e)
|
|
422
|
+
.into()
|
|
423
|
+
}
|
|
424
|
+
StateError::IdentityToFreezeDoesNotExistError(e) => {
|
|
425
|
+
generic_consensus_error!(IdentityToFreezeDoesNotExistError, e).into()
|
|
426
|
+
}
|
|
427
|
+
StateError::DataContractNotFoundError(e) => {
|
|
428
|
+
generic_consensus_error!(DataContractNotFoundError, e).into()
|
|
429
|
+
}
|
|
430
|
+
StateError::InvalidTokenPositionStateError(e) => {
|
|
431
|
+
generic_consensus_error!(InvalidTokenPositionStateError, e).into()
|
|
432
|
+
}
|
|
418
433
|
}
|
|
419
434
|
}
|
|
420
435
|
|
|
@@ -813,6 +828,28 @@ fn from_basic_error(basic_error: &BasicError) -> JsValue {
|
|
|
813
828
|
BasicError::GroupRequiredPowerIsInvalidError(e) => {
|
|
814
829
|
generic_consensus_error!(GroupRequiredPowerIsInvalidError, e).into()
|
|
815
830
|
}
|
|
831
|
+
BasicError::TokenNoteOnlyAllowedWhenProposerError(e) => {
|
|
832
|
+
generic_consensus_error!(TokenNoteOnlyAllowedWhenProposerError, e).into()
|
|
833
|
+
}
|
|
834
|
+
BasicError::InvalidTokenDistributionBlockIntervalTooShortError(e) => {
|
|
835
|
+
generic_consensus_error!(InvalidTokenDistributionBlockIntervalTooShortError, e).into()
|
|
836
|
+
}
|
|
837
|
+
BasicError::InvalidTokenDistributionTimeIntervalTooShortError(e) => {
|
|
838
|
+
generic_consensus_error!(InvalidTokenDistributionTimeIntervalTooShortError, e).into()
|
|
839
|
+
}
|
|
840
|
+
BasicError::InvalidTokenDistributionTimeIntervalNotMinuteAlignedError(e) => {
|
|
841
|
+
generic_consensus_error!(InvalidTokenDistributionTimeIntervalNotMinuteAlignedError, e)
|
|
842
|
+
.into()
|
|
843
|
+
}
|
|
844
|
+
BasicError::RedundantDocumentPaidForByTokenWithContractId(e) => {
|
|
845
|
+
generic_consensus_error!(RedundantDocumentPaidForByTokenWithContractId, e).into()
|
|
846
|
+
}
|
|
847
|
+
BasicError::GroupHasTooFewMembersError(e) => {
|
|
848
|
+
generic_consensus_error!(GroupHasTooFewMembersError, e).into()
|
|
849
|
+
}
|
|
850
|
+
BasicError::InvalidKeyPurposeForContractBoundsError(e) => {
|
|
851
|
+
generic_consensus_error!(InvalidKeyPurposeForContractBoundsError, e).into()
|
|
852
|
+
}
|
|
816
853
|
}
|
|
817
854
|
}
|
|
818
855
|
|
|
@@ -46,6 +46,12 @@ describe('DataContractCreateTransition', () => {
|
|
|
46
46
|
|
|
47
47
|
expect(result.toObject()).to.deep.equal(dataContract.toObject());
|
|
48
48
|
});
|
|
49
|
+
|
|
50
|
+
it('should return Data Contract with specific protocol version', () => {
|
|
51
|
+
const result = stateTransition.getDataContract(1);
|
|
52
|
+
|
|
53
|
+
expect(result.toObject()).to.deep.equal(dataContract.toObject());
|
|
54
|
+
});
|
|
49
55
|
});
|
|
50
56
|
|
|
51
57
|
describe.skip('#toJSON', () => {
|
|
@@ -66,7 +72,7 @@ describe('DataContractCreateTransition', () => {
|
|
|
66
72
|
it('should return serialized State Transition', () => {
|
|
67
73
|
const result = stateTransition.toBuffer();
|
|
68
74
|
expect(result).to.be.instanceOf(Buffer);
|
|
69
|
-
expect(result).to.have.lengthOf(
|
|
75
|
+
expect(result).to.have.lengthOf(2359);
|
|
70
76
|
});
|
|
71
77
|
|
|
72
78
|
it('should be able to restore contract config from bytes', () => {
|
|
@@ -65,7 +65,7 @@ describe('DataContractUpdateTransition', () => {
|
|
|
65
65
|
it('should return serialized State Transition', () => {
|
|
66
66
|
const result = stateTransition.toBuffer();
|
|
67
67
|
expect(result).to.be.instanceOf(Buffer);
|
|
68
|
-
expect(result).to.have.lengthOf(
|
|
68
|
+
expect(result).to.have.lengthOf(2359);
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
it('should be able to restore contract config from bytes', () => {
|