@dashevo/wasm-dpp 2.0.0-dev.1 → 2.0.0-rc.2
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 +9 -6
- package/README.md +1 -1
- package/dist/wasm/wasm_dpp.d.ts +1225 -1033
- package/dist/wasm/wasm_dpp.js +200 -101
- package/dist/wasm/wasm_dpp_bg.js +1 -1
- package/lib/wasm/wasm_dpp.d.ts +1225 -1033
- package/package.json +2 -2
- package/src/data_contract/data_contract.rs +1 -3
- package/src/data_contract/state_transition/data_contract_create_transition/mod.rs +1 -1
- package/src/data_contract/state_transition/data_contract_update_transition/mod.rs +2 -2
- package/src/data_contract/tokens.rs +3 -3
- package/src/data_contract_factory/mod.rs +1 -1
- package/src/document/extended_document.rs +1 -1
- package/src/document/factory.rs +12 -3
- package/src/document/mod.rs +4 -4
- package/src/document/state_transition/batch_transition/document_transition/mod.rs +2 -4
- package/src/document/state_transition/batch_transition/mod.rs +1 -2
- package/src/document/state_transition/batch_transition/token_transition/direct_purchase.rs +12 -0
- package/src/document/state_transition/batch_transition/token_transition/mod.rs +18 -11
- package/src/document/state_transition/batch_transition/token_transition/set_price_for_direct_purchase.rs +14 -0
- package/src/errors/consensus/basic/state_transition/missing_state_transition_type_error.rs +6 -0
- package/src/errors/consensus/consensus_error.rs +47 -2
- package/src/errors/consensus/fee/balance_is_not_enough_error.rs +1 -1
- package/src/errors/consensus/state/identity/invalid_identity_contract_nonce_error.rs +1 -1
- package/src/errors/value_error.rs +1 -0
- package/src/identity/identity.rs +1 -1
- package/src/identity/mod.rs +1 -0
- package/src/identity/state_transition/identity_create_transition/mod.rs +2 -2
- package/src/identity/state_transition/identity_create_transition/{identity_create_transition.rs → transition.rs} +1 -1
- package/src/identity/state_transition/identity_credit_withdrawal_transition/transition.rs +1 -1
- package/src/identity/state_transition/identity_public_key_transitions.rs +2 -2
- package/src/identity/state_transition/identity_topup_transition/mod.rs +2 -2
- package/src/identity/state_transition/identity_topup_transition/{identity_topup_transition.rs → transition.rs} +1 -1
- package/src/identity/state_transition/identity_update_transition/mod.rs +2 -2
- package/src/state_transition/errors/mod.rs +1 -0
- package/src/state_transition/errors/state_transition_is_not_active_error.rs +79 -0
- package/src/state_transition/state_transition_factory.rs +11 -0
- package/src/utils.rs +4 -2
- package/src/voting/state_transition/masternode_vote_transition/mod.rs +2 -2
- package/src/voting/state_transition/masternode_vote_transition/to_object.rs +1 -0
- /package/src/data_contract_factory/{data_contract_factory.rs → factory.rs} +0 -0
- /package/src/identity/state_transition/identity_update_transition/{identity_update_transition.rs → transition.rs} +0 -0
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-rc.2",
|
|
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-rc.2",
|
|
48
48
|
"@types/bs58": "^4.0.1",
|
|
49
49
|
"@types/node": "^14.6.0",
|
|
50
50
|
"@yarnpkg/pnpify": "^4.0.0-rc.42",
|
|
@@ -25,10 +25,9 @@ use dpp::ProtocolError;
|
|
|
25
25
|
|
|
26
26
|
use crate::data_contract::tokens::TokenConfigurationWasm;
|
|
27
27
|
use crate::identifier::identifier_from_js_value;
|
|
28
|
-
use crate::metadata::MetadataWasm;
|
|
29
28
|
use crate::utils::get_bool_from_options;
|
|
30
29
|
use crate::utils::SKIP_VALIDATION_PROPERTY_NAME;
|
|
31
|
-
use crate::utils::{Inner,
|
|
30
|
+
use crate::utils::{Inner, ToSerdeJSONExt, WithJsError};
|
|
32
31
|
use crate::with_js_error;
|
|
33
32
|
use crate::{buffer::Buffer, identifier::IdentifierWrapper};
|
|
34
33
|
|
|
@@ -439,7 +438,6 @@ impl DataContractWasm {
|
|
|
439
438
|
) -> Result<TokenConfigurationWasm, JsValue> {
|
|
440
439
|
self.inner
|
|
441
440
|
.expected_token_configuration(token_contract_position)
|
|
442
|
-
.map_err(ProtocolError::from)
|
|
443
441
|
.with_js_error()
|
|
444
442
|
.map(|token_configuration| token_configuration.clone().into())
|
|
445
443
|
}
|
|
@@ -75,7 +75,7 @@ impl DataContractUpdateTransitionWasm {
|
|
|
75
75
|
|
|
76
76
|
#[wasm_bindgen(js_name=getIdentityContractNonce)]
|
|
77
77
|
pub fn get_identity_contract_nonce(&self) -> u64 {
|
|
78
|
-
self.0.identity_contract_nonce()
|
|
78
|
+
self.0.identity_contract_nonce()
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
#[wasm_bindgen(js_name=getType)]
|
|
@@ -85,7 +85,7 @@ impl DataContractUpdateTransitionWasm {
|
|
|
85
85
|
|
|
86
86
|
#[wasm_bindgen(js_name=getUserFeeIncrease)]
|
|
87
87
|
pub fn get_user_fee_increase(&self) -> u16 {
|
|
88
|
-
self.0.user_fee_increase()
|
|
88
|
+
self.0.user_fee_increase()
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
#[wasm_bindgen(js_name=setUserFeeIncrease)]
|
|
@@ -14,9 +14,9 @@ impl From<TokenConfiguration> for TokenConfigurationWasm {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
impl
|
|
18
|
-
fn
|
|
19
|
-
|
|
17
|
+
impl From<TokenConfigurationWasm> for TokenConfiguration {
|
|
18
|
+
fn from(val: TokenConfigurationWasm) -> Self {
|
|
19
|
+
val.0
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
mod
|
|
1
|
+
mod factory;
|
package/src/document/factory.rs
CHANGED
|
@@ -22,9 +22,9 @@ use crate::{
|
|
|
22
22
|
};
|
|
23
23
|
use dpp::identifier::Identifier;
|
|
24
24
|
use dpp::state_transition::batch_transition::batched_transition::document_transition_action_type::DocumentTransitionActionType;
|
|
25
|
+
use dpp::tokens::token_payment_info::TokenPaymentInfo;
|
|
25
26
|
use dpp::version::PlatformVersion;
|
|
26
27
|
use std::convert::TryFrom;
|
|
27
|
-
use std::str::FromStr;
|
|
28
28
|
|
|
29
29
|
#[wasm_bindgen(js_name=DocumentTransitions)]
|
|
30
30
|
#[derive(Debug, Default)]
|
|
@@ -155,13 +155,20 @@ impl DocumentFactoryWASM {
|
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
+
// TODO: use types or structs
|
|
159
|
+
#[allow(clippy::type_complexity)]
|
|
158
160
|
let documents: Vec<(
|
|
159
161
|
DocumentTransitionActionType,
|
|
160
|
-
Vec<(Document, DocumentTypeRef, Bytes32)>,
|
|
162
|
+
Vec<(Document, DocumentTypeRef, Bytes32, Option<TokenPaymentInfo>)>,
|
|
161
163
|
)> = documents_by_action
|
|
162
164
|
.iter()
|
|
163
165
|
.map(|(action_type, documents)| {
|
|
164
|
-
let documents_with_refs: Vec<(
|
|
166
|
+
let documents_with_refs: Vec<(
|
|
167
|
+
Document,
|
|
168
|
+
DocumentTypeRef,
|
|
169
|
+
Bytes32,
|
|
170
|
+
Option<TokenPaymentInfo>,
|
|
171
|
+
)> = documents
|
|
165
172
|
.iter()
|
|
166
173
|
.map(|extended_document| {
|
|
167
174
|
(
|
|
@@ -171,6 +178,7 @@ impl DocumentFactoryWASM {
|
|
|
171
178
|
.document_type_for_name(extended_document.document_type_name())
|
|
172
179
|
.expect("should be able to get document type"),
|
|
173
180
|
extended_document.entropy().to_owned(),
|
|
181
|
+
extended_document.token_payment_info(),
|
|
174
182
|
)
|
|
175
183
|
})
|
|
176
184
|
.collect();
|
|
@@ -325,6 +333,7 @@ fn extract_documents_of_action(
|
|
|
325
333
|
return Ok(vec![]);
|
|
326
334
|
}
|
|
327
335
|
|
|
336
|
+
#[allow(clippy::unnecessary_fallible_conversions)]
|
|
328
337
|
let documents_array = js_sys::Array::try_from(documents_with_action)
|
|
329
338
|
.map_err(|e| anyhow!("property '{}' isn't an array: {}", action, e))?;
|
|
330
339
|
|
package/src/document/mod.rs
CHANGED
|
@@ -127,12 +127,12 @@ impl DocumentWasm {
|
|
|
127
127
|
|
|
128
128
|
#[wasm_bindgen(js_name=setRevision)]
|
|
129
129
|
pub fn set_revision(&mut self, revision: Option<u64>) {
|
|
130
|
-
self.0.set_revision(revision
|
|
130
|
+
self.0.set_revision(revision);
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
#[wasm_bindgen(js_name=getRevision)]
|
|
134
134
|
pub fn get_revision(&self) -> Option<u64> {
|
|
135
|
-
self.0.revision()
|
|
135
|
+
self.0.revision()
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
#[wasm_bindgen(js_name=setData)]
|
|
@@ -342,8 +342,8 @@ impl DocumentWasm {
|
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
344
|
|
|
345
|
-
/// document's dynamic data, regardless they are identifiers or binary, they should
|
|
346
|
-
/// be stored as arrays of int
|
|
345
|
+
// /// document's dynamic data, regardless they are identifiers or binary, they should
|
|
346
|
+
// /// be stored as arrays of int
|
|
347
347
|
// pub(crate) fn document_data_to_bytes(
|
|
348
348
|
// document: &mut Document,
|
|
349
349
|
// contract: &DataContract,
|
|
@@ -19,11 +19,11 @@ use wasm_bindgen::prelude::*;
|
|
|
19
19
|
use dpp::fee::Credits;
|
|
20
20
|
use dpp::platform_value::converter::serde_json::BTreeValueJsonConverter;
|
|
21
21
|
use dpp::prelude::Revision;
|
|
22
|
-
use dpp::state_transition::batch_transition::document_base_transition::DocumentBaseTransition;
|
|
23
22
|
use dpp::state_transition::batch_transition::document_replace_transition::v0::v0_methods::DocumentReplaceTransitionV0Methods;
|
|
24
23
|
use dpp::state_transition::batch_transition::batched_transition::document_purchase_transition::v0::v0_methods::DocumentPurchaseTransitionV0Methods;
|
|
25
24
|
use dpp::state_transition::batch_transition::batched_transition::document_transfer_transition::v0::v0_methods::DocumentTransferTransitionV0Methods;
|
|
26
25
|
use dpp::state_transition::batch_transition::batched_transition::document_update_price_transition::v0::v0_methods::DocumentUpdatePriceTransitionV0Methods;
|
|
26
|
+
use dpp::state_transition::batch_transition::document_base_transition::v0::v0_methods::DocumentBaseTransitionV0Methods;
|
|
27
27
|
use crate::{
|
|
28
28
|
buffer::Buffer,
|
|
29
29
|
identifier::{identifier_from_js_value, IdentifierWrapper},
|
|
@@ -89,9 +89,7 @@ impl DocumentTransitionWasm {
|
|
|
89
89
|
|
|
90
90
|
#[wasm_bindgen(js_name=getIdentityContractNonce)]
|
|
91
91
|
pub fn get_identity_contract_nonce(&self) -> JsValue {
|
|
92
|
-
|
|
93
|
-
DocumentBaseTransition::V0(v0) => JsValue::from(v0.identity_contract_nonce),
|
|
94
|
-
}
|
|
92
|
+
JsValue::from(self.0.base().identity_contract_nonce())
|
|
95
93
|
}
|
|
96
94
|
|
|
97
95
|
#[wasm_bindgen(js_name=getRevision)]
|
|
@@ -25,7 +25,6 @@ use crate::{
|
|
|
25
25
|
IdentityPublicKeyWasm,
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
use dpp::ed25519_dalek::ed25519::signature::SignerMut;
|
|
29
28
|
use dpp::state_transition::batch_transition::batched_transition::BatchedTransition;
|
|
30
29
|
use dpp::state_transition::batch_transition::methods::v0::DocumentsBatchTransitionMethodsV0;
|
|
31
30
|
|
|
@@ -105,7 +104,7 @@ impl BatchTransitionWasm {
|
|
|
105
104
|
|
|
106
105
|
#[wasm_bindgen(js_name=getUserFeeIncrease)]
|
|
107
106
|
pub fn get_user_fee_increase(&self) -> u16 {
|
|
108
|
-
self.0.user_fee_increase()
|
|
107
|
+
self.0.user_fee_increase()
|
|
109
108
|
}
|
|
110
109
|
|
|
111
110
|
#[wasm_bindgen(js_name=setUserFeeIncrease)]
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
use dpp::state_transition::batch_transition::TokenDirectPurchaseTransition;
|
|
2
|
+
use wasm_bindgen::prelude::wasm_bindgen;
|
|
3
|
+
|
|
4
|
+
#[wasm_bindgen(js_name=TokenDirectPurchaseTransition)]
|
|
5
|
+
#[derive(Debug, Clone)]
|
|
6
|
+
pub struct TokenDirectPurchaseTransitionWasm(TokenDirectPurchaseTransition);
|
|
7
|
+
|
|
8
|
+
impl From<TokenDirectPurchaseTransition> for TokenDirectPurchaseTransitionWasm {
|
|
9
|
+
fn from(value: TokenDirectPurchaseTransition) -> Self {
|
|
10
|
+
Self(value)
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -2,9 +2,11 @@ pub mod burn;
|
|
|
2
2
|
mod claim;
|
|
3
3
|
pub mod config;
|
|
4
4
|
pub mod destroy;
|
|
5
|
+
pub mod direct_purchase;
|
|
5
6
|
pub mod emergency_action;
|
|
6
7
|
pub mod freeze;
|
|
7
8
|
pub mod mint;
|
|
9
|
+
pub mod set_price_for_direct_purchase;
|
|
8
10
|
pub mod transfer;
|
|
9
11
|
pub mod unfreeze;
|
|
10
12
|
|
|
@@ -12,9 +14,11 @@ use crate::batch_transition::token_transition::burn::TokenBurnTransitionWasm;
|
|
|
12
14
|
use crate::batch_transition::token_transition::claim::TokenClaimTransitionWasm;
|
|
13
15
|
use crate::batch_transition::token_transition::config::TokenConfigUpdateTransitionWasm;
|
|
14
16
|
use crate::batch_transition::token_transition::destroy::TokenDestroyFrozenFundsTransitionWasm;
|
|
17
|
+
use crate::batch_transition::token_transition::direct_purchase::TokenDirectPurchaseTransitionWasm;
|
|
15
18
|
use crate::batch_transition::token_transition::emergency_action::TokenEmergencyActionTransitionWasm;
|
|
16
19
|
use crate::batch_transition::token_transition::freeze::TokenFreezeTransitionWasm;
|
|
17
20
|
use crate::batch_transition::token_transition::mint::TokenMintTransitionWasm;
|
|
21
|
+
use crate::batch_transition::token_transition::set_price_for_direct_purchase::TokenSetPriceForDirectPurchaseTransitionWasm;
|
|
18
22
|
use crate::batch_transition::token_transition::transfer::TokenTransferTransitionWasm;
|
|
19
23
|
use crate::batch_transition::token_transition::unfreeze::TokenUnfreezeTransitionWasm;
|
|
20
24
|
use crate::identifier::IdentifierWrapper;
|
|
@@ -23,9 +27,6 @@ use dpp::state_transition::batch_transition::batched_transition::token_transitio
|
|
|
23
27
|
TokenTransition, TokenTransitionV0Methods,
|
|
24
28
|
};
|
|
25
29
|
use dpp::state_transition::batch_transition::token_base_transition::v0::v0_methods::TokenBaseTransitionV0Methods;
|
|
26
|
-
use dpp::state_transition::batch_transition::token_base_transition::v0::TokenBaseTransitionV0;
|
|
27
|
-
use dpp::state_transition::batch_transition::token_mint_transition::TokenMintTransitionV0;
|
|
28
|
-
use dpp::state_transition::batch_transition::TokenMintTransition;
|
|
29
30
|
use js_sys::Number;
|
|
30
31
|
use wasm_bindgen::prelude::wasm_bindgen;
|
|
31
32
|
use wasm_bindgen::JsValue;
|
|
@@ -41,6 +42,8 @@ pub enum TokenTransitionType {
|
|
|
41
42
|
Claim,
|
|
42
43
|
EmergencyAction,
|
|
43
44
|
ConfigUpdate,
|
|
45
|
+
DirectPurchase,
|
|
46
|
+
SetPriceForDirectPurchase,
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
impl From<&TokenTransition> for TokenTransitionType {
|
|
@@ -55,6 +58,10 @@ impl From<&TokenTransition> for TokenTransitionType {
|
|
|
55
58
|
TokenTransition::EmergencyAction(_) => TokenTransitionType::EmergencyAction,
|
|
56
59
|
TokenTransition::ConfigUpdate(_) => TokenTransitionType::ConfigUpdate,
|
|
57
60
|
TokenTransition::Claim(_) => TokenTransitionType::Claim,
|
|
61
|
+
TokenTransition::DirectPurchase(_) => TokenTransitionType::DirectPurchase,
|
|
62
|
+
TokenTransition::SetPriceForDirectPurchase(_) => {
|
|
63
|
+
TokenTransitionType::SetPriceForDirectPurchase
|
|
64
|
+
}
|
|
58
65
|
}
|
|
59
66
|
}
|
|
60
67
|
}
|
|
@@ -103,14 +110,8 @@ impl TokenTransitionWasm {
|
|
|
103
110
|
}
|
|
104
111
|
|
|
105
112
|
#[wasm_bindgen(js_name=getHistoricalDocumentId)]
|
|
106
|
-
pub fn historical_document_id(
|
|
107
|
-
|
|
108
|
-
owner_id: IdentifierWrapper,
|
|
109
|
-
owner_nonce: IdentityNonce,
|
|
110
|
-
) -> IdentifierWrapper {
|
|
111
|
-
self.0
|
|
112
|
-
.historical_document_id(owner_id.into(), owner_nonce)
|
|
113
|
-
.into()
|
|
113
|
+
pub fn historical_document_id(&self, owner_id: IdentifierWrapper) -> IdentifierWrapper {
|
|
114
|
+
self.0.historical_document_id(owner_id.into()).into()
|
|
114
115
|
}
|
|
115
116
|
|
|
116
117
|
#[wasm_bindgen(js_name=getIdentityContractNonce)]
|
|
@@ -142,6 +143,12 @@ impl TokenTransitionWasm {
|
|
|
142
143
|
TokenConfigUpdateTransitionWasm::from(config_update.clone()).into()
|
|
143
144
|
}
|
|
144
145
|
TokenTransition::Claim(claim) => TokenClaimTransitionWasm::from(claim.clone()).into(),
|
|
146
|
+
TokenTransition::DirectPurchase(direct_purchase) => {
|
|
147
|
+
TokenDirectPurchaseTransitionWasm::from(direct_purchase.clone()).into()
|
|
148
|
+
}
|
|
149
|
+
TokenTransition::SetPriceForDirectPurchase(set_price) => {
|
|
150
|
+
TokenSetPriceForDirectPurchaseTransitionWasm::from(set_price.clone()).into()
|
|
151
|
+
}
|
|
145
152
|
}
|
|
146
153
|
}
|
|
147
154
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
use dpp::state_transition::batch_transition::TokenSetPriceForDirectPurchaseTransition;
|
|
2
|
+
use wasm_bindgen::prelude::wasm_bindgen;
|
|
3
|
+
|
|
4
|
+
#[wasm_bindgen(js_name=TokenSetPriceForDirectPurchaseTransition)]
|
|
5
|
+
#[derive(Debug, Clone)]
|
|
6
|
+
pub struct TokenSetPriceForDirectPurchaseTransitionWasm(TokenSetPriceForDirectPurchaseTransition);
|
|
7
|
+
|
|
8
|
+
impl From<TokenSetPriceForDirectPurchaseTransition>
|
|
9
|
+
for TokenSetPriceForDirectPurchaseTransitionWasm
|
|
10
|
+
{
|
|
11
|
+
fn from(value: TokenSetPriceForDirectPurchaseTransition) -> Self {
|
|
12
|
+
Self(value)
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -15,6 +15,12 @@ impl From<&MissingStateTransitionTypeError> for MissingStateTransitionTypeErrorW
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
impl Default for MissingStateTransitionTypeErrorWasm {
|
|
19
|
+
fn default() -> Self {
|
|
20
|
+
Self::new()
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
18
24
|
#[wasm_bindgen(js_class=MissingStateTransitionTypeError)]
|
|
19
25
|
impl MissingStateTransitionTypeErrorWasm {
|
|
20
26
|
#[wasm_bindgen(constructor)]
|
|
@@ -61,7 +61,7 @@ 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, GroupExceedsMaxMembersError, GroupMemberHasPowerOfZeroError, GroupMemberHasPowerOverLimitError, GroupNonUnilateralMemberPowerHasLessThanRequiredPowerError, GroupPositionDoesNotExistError, GroupTotalPowerLessThanRequiredError, InvalidDocumentTypeRequiredSecurityLevelError, InvalidTokenBaseSupplyError, InvalidTokenDistributionFunctionDivideByZeroError, InvalidTokenDistributionFunctionIncoherenceError, InvalidTokenDistributionFunctionInvalidParameterError, InvalidTokenDistributionFunctionInvalidParameterTupleError, NonContiguousContractGroupPositionsError, NonContiguousContractTokenPositionsError, UnknownDocumentCreationRestrictionModeError, UnknownSecurityLevelError, UnknownStorageKeyRequirementsError, UnknownTradeModeError, UnknownTransferableTypeError};
|
|
64
|
+
use dpp::consensus::basic::data_contract::{ContestedUniqueIndexOnMutableDocumentTypeError, ContestedUniqueIndexWithUniqueIndexError, DataContractTokenConfigurationUpdateError, DuplicateKeywordsError, GroupExceedsMaxMembersError, GroupMemberHasPowerOfZeroError, GroupMemberHasPowerOverLimitError, GroupNonUnilateralMemberPowerHasLessThanRequiredPowerError, GroupPositionDoesNotExistError, GroupTotalPowerLessThanRequiredError, InvalidDescriptionLengthError, InvalidDocumentTypeRequiredSecurityLevelError, InvalidKeywordLengthError, InvalidTokenBaseSupplyError, InvalidTokenDistributionFunctionDivideByZeroError, InvalidTokenDistributionFunctionIncoherenceError, InvalidTokenDistributionFunctionInvalidParameterError, InvalidTokenDistributionFunctionInvalidParameterTupleError, NonContiguousContractGroupPositionsError, NonContiguousContractTokenPositionsError, 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
67
|
use dpp::consensus::basic::identity::{DataContractBoundsNotPresentError, DisablingKeyIdAlsoBeingAddedInSameTransitionError, InvalidIdentityCreditWithdrawalTransitionAmountError, InvalidIdentityUpdateTransitionDisableKeysError, InvalidIdentityUpdateTransitionEmptyError, TooManyMasterPublicKeyError, WithdrawalOutputScriptNotAllowedWhenSigningWithOwnerKeyError};
|
|
@@ -84,7 +84,7 @@ use dpp::consensus::state::identity::no_transfer_key_for_core_withdrawal_availab
|
|
|
84
84
|
use dpp::consensus::state::identity::RecipientIdentityDoesNotExistError;
|
|
85
85
|
use dpp::consensus::state::prefunded_specialized_balances::prefunded_specialized_balance_insufficient_error::PrefundedSpecializedBalanceInsufficientError;
|
|
86
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};
|
|
87
|
+
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};
|
|
88
88
|
use dpp::consensus::state::voting::masternode_incorrect_voter_identity_id_error::MasternodeIncorrectVoterIdentityIdError;
|
|
89
89
|
use dpp::consensus::state::voting::masternode_incorrect_voting_address_error::MasternodeIncorrectVotingAddressError;
|
|
90
90
|
use dpp::consensus::state::voting::masternode_not_found_error::MasternodeNotFoundError;
|
|
@@ -384,6 +384,30 @@ pub fn from_state_error(state_error: &StateError) -> JsValue {
|
|
|
384
384
|
StateError::InvalidTokenClaimWrongClaimant(e) => {
|
|
385
385
|
generic_consensus_error!(InvalidTokenClaimWrongClaimant, e).into()
|
|
386
386
|
}
|
|
387
|
+
StateError::TokenTransferRecipientIdentityNotExistError(e) => {
|
|
388
|
+
generic_consensus_error!(TokenTransferRecipientIdentityNotExistError, e).into()
|
|
389
|
+
}
|
|
390
|
+
StateError::PreProgrammedDistributionTimestampInPastError(e) => {
|
|
391
|
+
generic_consensus_error!(PreProgrammedDistributionTimestampInPastError, e).into()
|
|
392
|
+
}
|
|
393
|
+
StateError::IdentityHasNotAgreedToPayRequiredTokenAmountError(e) => {
|
|
394
|
+
generic_consensus_error!(IdentityHasNotAgreedToPayRequiredTokenAmountError, e).into()
|
|
395
|
+
}
|
|
396
|
+
StateError::RequiredTokenPaymentInfoNotSetError(e) => {
|
|
397
|
+
generic_consensus_error!(RequiredTokenPaymentInfoNotSetError, e).into()
|
|
398
|
+
}
|
|
399
|
+
StateError::IdentityTryingToPayWithWrongTokenError(e) => {
|
|
400
|
+
generic_consensus_error!(IdentityTryingToPayWithWrongTokenError, e).into()
|
|
401
|
+
}
|
|
402
|
+
StateError::TokenDirectPurchaseUserPriceTooLow(e) => {
|
|
403
|
+
generic_consensus_error!(TokenDirectPurchaseUserPriceTooLow, e).into()
|
|
404
|
+
}
|
|
405
|
+
StateError::TokenAmountUnderMinimumSaleAmount(e) => {
|
|
406
|
+
generic_consensus_error!(TokenAmountUnderMinimumSaleAmount, e).into()
|
|
407
|
+
}
|
|
408
|
+
StateError::TokenNotForDirectSale(e) => {
|
|
409
|
+
generic_consensus_error!(TokenNotForDirectSale, e).into()
|
|
410
|
+
}
|
|
387
411
|
}
|
|
388
412
|
}
|
|
389
413
|
|
|
@@ -737,6 +761,27 @@ fn from_basic_error(basic_error: &BasicError) -> JsValue {
|
|
|
737
761
|
BasicError::MissingDefaultLocalizationError(e) => {
|
|
738
762
|
generic_consensus_error!(MissingDefaultLocalizationError, e).into()
|
|
739
763
|
}
|
|
764
|
+
BasicError::UnknownGasFeesPaidByError(e) => {
|
|
765
|
+
generic_consensus_error!(UnknownGasFeesPaidByError, e).into()
|
|
766
|
+
}
|
|
767
|
+
BasicError::UnknownDocumentActionTokenEffectError(e) => {
|
|
768
|
+
generic_consensus_error!(UnknownDocumentActionTokenEffectError, e).into()
|
|
769
|
+
}
|
|
770
|
+
BasicError::TokenPaymentByBurningOnlyAllowedOnInternalTokenError(e) => {
|
|
771
|
+
generic_consensus_error!(TokenPaymentByBurningOnlyAllowedOnInternalTokenError, e).into()
|
|
772
|
+
}
|
|
773
|
+
BasicError::TooManyKeywordsError(e) => {
|
|
774
|
+
generic_consensus_error!(TooManyKeywordsError, e).into()
|
|
775
|
+
}
|
|
776
|
+
BasicError::DuplicateKeywordsError(e) => {
|
|
777
|
+
generic_consensus_error!(DuplicateKeywordsError, e).into()
|
|
778
|
+
}
|
|
779
|
+
BasicError::InvalidKeywordLengthError(e) => {
|
|
780
|
+
generic_consensus_error!(InvalidKeywordLengthError, e).into()
|
|
781
|
+
}
|
|
782
|
+
BasicError::InvalidDescriptionLengthError(e) => {
|
|
783
|
+
generic_consensus_error!(InvalidDescriptionLengthError, e).into()
|
|
784
|
+
}
|
|
740
785
|
}
|
|
741
786
|
}
|
|
742
787
|
|
|
@@ -31,7 +31,7 @@ impl InvalidIdentityNonceErrorWasm {
|
|
|
31
31
|
|
|
32
32
|
#[wasm_bindgen(js_name=getSettingIdentityContractNonce)]
|
|
33
33
|
pub fn setting_identity_contract_nonce(&self) -> u64 {
|
|
34
|
-
*self.inner.setting_identity_contract_nonce()
|
|
34
|
+
*self.inner.setting_identity_contract_nonce()
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
#[wasm_bindgen(js_name=getError)]
|
package/src/identity/identity.rs
CHANGED
package/src/identity/mod.rs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
pub use
|
|
1
|
+
pub use transition::*;
|
|
2
2
|
|
|
3
3
|
// pub mod apply_identity_create_transition;
|
|
4
|
-
pub mod
|
|
4
|
+
pub mod transition;
|
|
5
5
|
// pub mod identity_create_transition_basic_validator;
|
|
6
6
|
// pub mod identity_create_transition_state_validator;
|
|
7
7
|
|
|
@@ -169,7 +169,7 @@ impl IdentityCreateTransitionWasm {
|
|
|
169
169
|
|
|
170
170
|
#[wasm_bindgen(js_name=getUserFeeIncrease)]
|
|
171
171
|
pub fn get_user_fee_increase(&self) -> u16 {
|
|
172
|
-
self.0.user_fee_increase()
|
|
172
|
+
self.0.user_fee_increase()
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
#[wasm_bindgen(js_name=setUserFeeIncrease)]
|
|
@@ -138,7 +138,7 @@ impl IdentityCreditWithdrawalTransitionWasm {
|
|
|
138
138
|
|
|
139
139
|
#[wasm_bindgen(js_name=getUserFeeIncrease)]
|
|
140
140
|
pub fn get_user_fee_increase(&self) -> u16 {
|
|
141
|
-
self.0.user_fee_increase()
|
|
141
|
+
self.0.user_fee_increase()
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
#[wasm_bindgen(js_name=setUserFeeIncrease)]
|
|
@@ -111,10 +111,10 @@ impl IdentityPublicKeyWithWitnessWasm {
|
|
|
111
111
|
contract_id: IdentifierWrapper,
|
|
112
112
|
document_type_name: Option<String>,
|
|
113
113
|
) {
|
|
114
|
-
let contract_bounds = if
|
|
114
|
+
let contract_bounds = if let Some(name) = document_type_name {
|
|
115
115
|
ContractBounds::SingleContractDocumentType {
|
|
116
116
|
id: contract_id.into(),
|
|
117
|
-
document_type_name:
|
|
117
|
+
document_type_name: name,
|
|
118
118
|
}
|
|
119
119
|
} else {
|
|
120
120
|
ContractBounds::SingleContract {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
pub use
|
|
1
|
+
pub use transition::*;
|
|
2
2
|
|
|
3
3
|
// pub mod apply_identity_topup_transition;
|
|
4
|
-
pub mod
|
|
4
|
+
pub mod transition;
|
|
5
5
|
// pub mod identity_topup_transition_basic_validator;
|
|
6
6
|
// pub mod identity_topup_transition_state_validator;
|
|
7
7
|
|
|
@@ -117,7 +117,7 @@ impl IdentityTopUpTransitionWasm {
|
|
|
117
117
|
|
|
118
118
|
#[wasm_bindgen(js_name=getUserFeeIncrease)]
|
|
119
119
|
pub fn get_user_fee_increase(&self) -> u16 {
|
|
120
|
-
self.0.user_fee_increase()
|
|
120
|
+
self.0.user_fee_increase()
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
#[wasm_bindgen(js_name=setUserFeeIncrease)]
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
pub use
|
|
1
|
+
pub use transition::*;
|
|
2
2
|
|
|
3
3
|
// pub mod apply_identity_update_transition;
|
|
4
4
|
// pub mod identity_update_public_keys_validator;
|
|
5
|
-
pub mod
|
|
5
|
+
pub mod transition;
|
|
6
6
|
// pub mod identity_update_transition_basic_validator;
|
|
7
7
|
// pub mod identity_update_transition_state_validator;
|
|
8
8
|
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
use dpp::version::ProtocolVersion;
|
|
2
|
+
use std::ops::RangeInclusive;
|
|
3
|
+
use wasm_bindgen::prelude::*;
|
|
4
|
+
|
|
5
|
+
#[wasm_bindgen(js_name = StateTransitionIsNotActiveError)]
|
|
6
|
+
pub struct StateTransitionIsNotActiveErrorWasm {
|
|
7
|
+
state_transition_type: String,
|
|
8
|
+
active_version_range_start: ProtocolVersion,
|
|
9
|
+
active_version_range_end: ProtocolVersion,
|
|
10
|
+
current_protocol_version: ProtocolVersion,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
impl StateTransitionIsNotActiveErrorWasm {
|
|
14
|
+
pub fn new(
|
|
15
|
+
state_transition_type: String,
|
|
16
|
+
active_version_range: RangeInclusive<ProtocolVersion>,
|
|
17
|
+
current_protocol_version: ProtocolVersion,
|
|
18
|
+
) -> Self {
|
|
19
|
+
Self {
|
|
20
|
+
state_transition_type,
|
|
21
|
+
active_version_range_start: *active_version_range.start(),
|
|
22
|
+
active_version_range_end: *active_version_range.end(),
|
|
23
|
+
current_protocol_version,
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
#[wasm_bindgen(js_class = StateTransitionIsNotActiveError)]
|
|
29
|
+
impl StateTransitionIsNotActiveErrorWasm {
|
|
30
|
+
#[wasm_bindgen(js_name = getStateTransitionType)]
|
|
31
|
+
pub fn get_state_transition_type(&self) -> String {
|
|
32
|
+
self.state_transition_type.clone()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
#[wasm_bindgen(js_name = getActiveVersionRangeStart)]
|
|
36
|
+
pub fn get_active_version_range_start(&self) -> u32 {
|
|
37
|
+
self.active_version_range_start
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
#[wasm_bindgen(js_name = getActiveVersionRangeEnd)]
|
|
41
|
+
pub fn get_active_version_range_end(&self) -> u32 {
|
|
42
|
+
self.active_version_range_end
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
#[wasm_bindgen(js_name = getCurrentProtocolVersion)]
|
|
46
|
+
pub fn get_current_protocol_version(&self) -> u32 {
|
|
47
|
+
self.current_protocol_version
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
#[wasm_bindgen(js_name = toObject)]
|
|
51
|
+
pub fn to_object(&self) -> JsValue {
|
|
52
|
+
let object = js_sys::Object::new();
|
|
53
|
+
js_sys::Reflect::set(
|
|
54
|
+
&object,
|
|
55
|
+
&"stateTransitionType".into(),
|
|
56
|
+
&self.state_transition_type.clone().into(),
|
|
57
|
+
)
|
|
58
|
+
.unwrap();
|
|
59
|
+
js_sys::Reflect::set(
|
|
60
|
+
&object,
|
|
61
|
+
&"activeVersionRangeStart".into(),
|
|
62
|
+
&JsValue::from(self.active_version_range_start),
|
|
63
|
+
)
|
|
64
|
+
.unwrap();
|
|
65
|
+
js_sys::Reflect::set(
|
|
66
|
+
&object,
|
|
67
|
+
&"activeVersionRangeEnd".into(),
|
|
68
|
+
&JsValue::from(self.active_version_range_end),
|
|
69
|
+
)
|
|
70
|
+
.unwrap();
|
|
71
|
+
js_sys::Reflect::set(
|
|
72
|
+
&object,
|
|
73
|
+
&"currentProtocolVersion".into(),
|
|
74
|
+
&JsValue::from(self.current_protocol_version),
|
|
75
|
+
)
|
|
76
|
+
.unwrap();
|
|
77
|
+
object.into()
|
|
78
|
+
}
|
|
79
|
+
}
|