@dashevo/wasm-dpp 4.2.0-dev.9 → 5.0.0-beta.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/dist/wasm/wasm_dpp.d.ts +3845 -2470
- package/dist/wasm/wasm_dpp.js +707 -79
- package/dist/wasm/wasm_dpp_bg.js +1 -1
- package/lib/wasm/wasm_dpp.d.ts +3845 -2470
- package/package.json +2 -2
- package/src/data_contract/state_transition/data_contract_create_transition/mod.rs +8 -3
- package/src/data_contract/state_transition/data_contract_update_transition/mod.rs +8 -3
- package/src/document/factory.rs +1 -1
- package/src/document/state_transition/batch_transition/mod.rs +6 -1
- package/src/document/state_transition/batch_transition/token_transition/claim.rs +1 -0
- package/src/document/state_transition/batch_transition/token_transition/mod.rs +41 -14
- package/src/errors/consensus/basic/identity/contract_group_bound_key_not_allowed_in_shielded_identity_creation_error.rs +36 -0
- package/src/errors/consensus/basic/identity/mod.rs +2 -0
- package/src/errors/consensus/consensus_error.rs +403 -4
- package/src/errors/consensus/deserialize.rs +2 -2
- package/src/errors/consensus/signature/contract_bounded_key_non_batch_error.rs +29 -0
- package/src/errors/consensus/signature/contract_bounded_key_out_of_bounds_error.rs +29 -0
- package/src/errors/consensus/signature/mod.rs +6 -0
- package/src/identity/identity.rs +3 -2
- package/src/identity/identity_public_key/mod.rs +3 -2
- package/src/identity/mod.rs +1 -1
- package/src/identity/state_transition/identity_update_transition/transition.rs +5 -1
- package/src/state_transition/state_transition_factory.rs +12 -0
- package/src/utils.rs +2 -2
- package/src/validation/validation_result.rs +0 -8
- package/test/unit/dataContract/stateTransition/DataContractCreateTransition/DataContractCreateTransition.spec.js +3 -1
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/DataContractUpdateTransition.spec.js +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashevo/wasm-dpp",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-beta.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": "
|
|
47
|
+
"@dashevo/dpns-contract": "5.0.0-beta.2",
|
|
48
48
|
"@types/bs58": "^4.0.1",
|
|
49
49
|
"@types/node": "^20.10.0",
|
|
50
50
|
"@yarnpkg/pnpify": "^4.0.0-rc.42",
|
|
@@ -7,7 +7,7 @@ use crate::errors::protocol_error::from_protocol_error;
|
|
|
7
7
|
use dpp::errors::consensus::signature::SignatureError;
|
|
8
8
|
use dpp::errors::consensus::ConsensusError;
|
|
9
9
|
|
|
10
|
-
use dpp::serialization::{
|
|
10
|
+
use dpp::serialization::{PlatformDeserializableUntrusted, PlatformSerializable};
|
|
11
11
|
use dpp::state_transition::data_contract_create_transition::accessors::DataContractCreateTransitionAccessorsV0;
|
|
12
12
|
use dpp::state_transition::data_contract_create_transition::DataContractCreateTransition;
|
|
13
13
|
use dpp::state_transition::StateTransitionHasUserFeeIncrease;
|
|
@@ -169,7 +169,8 @@ impl DataContractCreateTransitionWasm {
|
|
|
169
169
|
#[wasm_bindgen(js_name=fromBuffer)]
|
|
170
170
|
pub fn from_buffer(buffer: Vec<u8>) -> Result<DataContractCreateTransitionWasm, JsValue> {
|
|
171
171
|
let state_transition: StateTransition =
|
|
172
|
-
|
|
172
|
+
PlatformDeserializableUntrusted::deserialize_from_bytes_untrusted(&buffer)
|
|
173
|
+
.with_js_error()?;
|
|
173
174
|
match state_transition {
|
|
174
175
|
StateTransition::DataContractCreate(dct) => Ok(dct.into()),
|
|
175
176
|
_ => Err(JsValue::from_str("Invalid state transition type")),
|
|
@@ -260,7 +261,11 @@ impl DataContractCreateTransitionWasm {
|
|
|
260
261
|
let bls_adapter = BlsAdapter(bls);
|
|
261
262
|
|
|
262
263
|
let verification_result = StateTransition::DataContractCreate(self.0.clone())
|
|
263
|
-
.verify_identity_signed_signature(
|
|
264
|
+
.verify_identity_signed_signature(
|
|
265
|
+
&identity_public_key.to_owned().into(),
|
|
266
|
+
&bls_adapter,
|
|
267
|
+
PlatformVersion::latest(),
|
|
268
|
+
);
|
|
264
269
|
|
|
265
270
|
match verification_result {
|
|
266
271
|
Ok(()) => Ok(true),
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
use dpp::consensus::ConsensusError;
|
|
6
6
|
use dpp::serialization::ValueConvertible;
|
|
7
|
-
use dpp::serialization::{
|
|
7
|
+
use dpp::serialization::{PlatformDeserializableUntrusted, PlatformSerializable};
|
|
8
8
|
use dpp::state_transition::data_contract_update_transition::accessors::DataContractUpdateTransitionAccessorsV0;
|
|
9
9
|
use dpp::state_transition::data_contract_update_transition::DataContractUpdateTransition;
|
|
10
10
|
use dpp::state_transition::StateTransition;
|
|
@@ -164,7 +164,8 @@ impl DataContractUpdateTransitionWasm {
|
|
|
164
164
|
#[wasm_bindgen(js_name=fromBuffer)]
|
|
165
165
|
pub fn from_buffer(buffer: Vec<u8>) -> Result<DataContractUpdateTransitionWasm, JsValue> {
|
|
166
166
|
let state_transition: StateTransition =
|
|
167
|
-
|
|
167
|
+
PlatformDeserializableUntrusted::deserialize_from_bytes_untrusted(&buffer)
|
|
168
|
+
.with_js_error()?;
|
|
168
169
|
match state_transition {
|
|
169
170
|
StateTransition::DataContractUpdate(dct) => Ok(dct.into()),
|
|
170
171
|
_ => Err(JsValue::from_str("Invalid state transition type")),
|
|
@@ -264,7 +265,11 @@ impl DataContractUpdateTransitionWasm {
|
|
|
264
265
|
let bls_adapter = BlsAdapter(bls);
|
|
265
266
|
|
|
266
267
|
let verification_result = StateTransition::DataContractUpdate(self.0.clone())
|
|
267
|
-
.verify_identity_signed_signature(
|
|
268
|
+
.verify_identity_signed_signature(
|
|
269
|
+
&identity_public_key.to_owned().into(),
|
|
270
|
+
&bls_adapter,
|
|
271
|
+
PlatformVersion::latest(),
|
|
272
|
+
);
|
|
268
273
|
|
|
269
274
|
match verification_result {
|
|
270
275
|
Ok(()) => Ok(true),
|
package/src/document/factory.rs
CHANGED
|
@@ -178,7 +178,7 @@ impl DocumentFactoryWASM {
|
|
|
178
178
|
.document_type_for_name(extended_document.document_type_name())
|
|
179
179
|
.expect("should be able to get document type"),
|
|
180
180
|
extended_document.entropy().to_owned(),
|
|
181
|
-
extended_document.
|
|
181
|
+
extended_document.token_payment_info_ref().clone(),
|
|
182
182
|
)
|
|
183
183
|
})
|
|
184
184
|
.collect();
|
|
@@ -33,6 +33,7 @@ use crate::batch_transition::batched_transition::BatchedTransitionWasm;
|
|
|
33
33
|
use crate::batch_transition::document_transition::DocumentTransitionWasm;
|
|
34
34
|
use crate::batch_transition::token_transition::TokenTransitionWasm;
|
|
35
35
|
use dpp::state_transition::StateTransitionIdentitySigned;
|
|
36
|
+
use dpp::version::PlatformVersion;
|
|
36
37
|
|
|
37
38
|
pub mod batched_transition;
|
|
38
39
|
pub mod document_transition;
|
|
@@ -340,7 +341,11 @@ impl BatchTransitionWasm {
|
|
|
340
341
|
let bls_adapter = BlsAdapter(bls);
|
|
341
342
|
|
|
342
343
|
let verification_result = StateTransition::Batch(self.0.clone())
|
|
343
|
-
.verify_identity_signed_signature(
|
|
344
|
+
.verify_identity_signed_signature(
|
|
345
|
+
&identity_public_key.to_owned().into(),
|
|
346
|
+
&bls_adapter,
|
|
347
|
+
PlatformVersion::latest(),
|
|
348
|
+
);
|
|
344
349
|
|
|
345
350
|
match verification_result {
|
|
346
351
|
Ok(()) => Ok(true),
|
|
@@ -44,6 +44,13 @@ pub enum TokenTransitionType {
|
|
|
44
44
|
ConfigUpdate,
|
|
45
45
|
DirectPurchase,
|
|
46
46
|
SetPriceForDirectPurchase,
|
|
47
|
+
Shield,
|
|
48
|
+
Unshield,
|
|
49
|
+
ShieldedTransfer,
|
|
50
|
+
MintToPool,
|
|
51
|
+
BurnFromPool,
|
|
52
|
+
ClaimToPool,
|
|
53
|
+
DirectPurchaseToPool,
|
|
47
54
|
}
|
|
48
55
|
|
|
49
56
|
impl From<&TokenTransition> for TokenTransitionType {
|
|
@@ -62,6 +69,13 @@ impl From<&TokenTransition> for TokenTransitionType {
|
|
|
62
69
|
TokenTransition::SetPriceForDirectPurchase(_) => {
|
|
63
70
|
TokenTransitionType::SetPriceForDirectPurchase
|
|
64
71
|
}
|
|
72
|
+
TokenTransition::Shield(_) => TokenTransitionType::Shield,
|
|
73
|
+
TokenTransition::Unshield(_) => TokenTransitionType::Unshield,
|
|
74
|
+
TokenTransition::ShieldedTransfer(_) => TokenTransitionType::ShieldedTransfer,
|
|
75
|
+
TokenTransition::MintToPool(_) => TokenTransitionType::MintToPool,
|
|
76
|
+
TokenTransition::BurnFromPool(_) => TokenTransitionType::BurnFromPool,
|
|
77
|
+
TokenTransition::ClaimToPool(_) => TokenTransitionType::ClaimToPool,
|
|
78
|
+
TokenTransition::DirectPurchaseToPool(_) => TokenTransitionType::DirectPurchaseToPool,
|
|
65
79
|
}
|
|
66
80
|
}
|
|
67
81
|
}
|
|
@@ -120,35 +134,48 @@ impl TokenTransitionWasm {
|
|
|
120
134
|
}
|
|
121
135
|
|
|
122
136
|
#[wasm_bindgen(js_name=toTransition)]
|
|
123
|
-
pub fn to_transition(&self) -> JsValue {
|
|
137
|
+
pub fn to_transition(&self) -> Result<JsValue, JsValue> {
|
|
124
138
|
match &self.0 {
|
|
125
|
-
TokenTransition::Burn(burn) => TokenBurnTransitionWasm::from(burn.clone()).into(),
|
|
126
|
-
TokenTransition::Mint(mint) => TokenMintTransitionWasm::from(mint.clone()).into(),
|
|
139
|
+
TokenTransition::Burn(burn) => Ok(TokenBurnTransitionWasm::from(burn.clone()).into()),
|
|
140
|
+
TokenTransition::Mint(mint) => Ok(TokenMintTransitionWasm::from(mint.clone()).into()),
|
|
127
141
|
TokenTransition::Transfer(transfer) => {
|
|
128
|
-
TokenTransferTransitionWasm::from(transfer.clone()).into()
|
|
142
|
+
Ok(TokenTransferTransitionWasm::from(transfer.clone()).into())
|
|
129
143
|
}
|
|
130
144
|
TokenTransition::Freeze(freeze) => {
|
|
131
|
-
TokenFreezeTransitionWasm::from(freeze.clone()).into()
|
|
145
|
+
Ok(TokenFreezeTransitionWasm::from(freeze.clone()).into())
|
|
132
146
|
}
|
|
133
147
|
TokenTransition::Unfreeze(unfreeze) => {
|
|
134
|
-
TokenUnfreezeTransitionWasm::from(unfreeze.clone()).into()
|
|
135
|
-
}
|
|
136
|
-
TokenTransition::DestroyFrozenFunds(destroy_frozen_funds) => {
|
|
137
|
-
TokenDestroyFrozenFundsTransitionWasm::from(destroy_frozen_funds.clone()).into()
|
|
148
|
+
Ok(TokenUnfreezeTransitionWasm::from(unfreeze.clone()).into())
|
|
138
149
|
}
|
|
150
|
+
TokenTransition::DestroyFrozenFunds(destroy_frozen_funds) => Ok(
|
|
151
|
+
TokenDestroyFrozenFundsTransitionWasm::from(destroy_frozen_funds.clone()).into(),
|
|
152
|
+
),
|
|
139
153
|
TokenTransition::EmergencyAction(emergency_action) => {
|
|
140
|
-
TokenEmergencyActionTransitionWasm::from(emergency_action.clone()).into()
|
|
154
|
+
Ok(TokenEmergencyActionTransitionWasm::from(emergency_action.clone()).into())
|
|
141
155
|
}
|
|
142
156
|
TokenTransition::ConfigUpdate(config_update) => {
|
|
143
|
-
TokenConfigUpdateTransitionWasm::from(config_update.clone()).into()
|
|
157
|
+
Ok(TokenConfigUpdateTransitionWasm::from(config_update.clone()).into())
|
|
158
|
+
}
|
|
159
|
+
TokenTransition::Claim(claim) => {
|
|
160
|
+
Ok(TokenClaimTransitionWasm::from(claim.clone()).into())
|
|
144
161
|
}
|
|
145
|
-
TokenTransition::Claim(claim) => TokenClaimTransitionWasm::from(claim.clone()).into(),
|
|
146
162
|
TokenTransition::DirectPurchase(direct_purchase) => {
|
|
147
|
-
TokenDirectPurchaseTransitionWasm::from(direct_purchase.clone()).into()
|
|
163
|
+
Ok(TokenDirectPurchaseTransitionWasm::from(direct_purchase.clone()).into())
|
|
148
164
|
}
|
|
149
165
|
TokenTransition::SetPriceForDirectPurchase(set_price) => {
|
|
150
|
-
TokenSetPriceForDirectPurchaseTransitionWasm::from(set_price.clone()).into()
|
|
166
|
+
Ok(TokenSetPriceForDirectPurchaseTransitionWasm::from(set_price.clone()).into())
|
|
151
167
|
}
|
|
168
|
+
// The shielded-pool token transition kinds have no wrapper class here, so there is
|
|
169
|
+
// nothing to hand back; wasm-dpp2 is the binding that exposes them.
|
|
170
|
+
TokenTransition::Shield(_)
|
|
171
|
+
| TokenTransition::Unshield(_)
|
|
172
|
+
| TokenTransition::ShieldedTransfer(_)
|
|
173
|
+
| TokenTransition::MintToPool(_)
|
|
174
|
+
| TokenTransition::BurnFromPool(_)
|
|
175
|
+
| TokenTransition::ClaimToPool(_)
|
|
176
|
+
| TokenTransition::DirectPurchaseToPool(_) => Err(JsValue::from_str(
|
|
177
|
+
"shielded and pool-backed token transitions are not supported in wasm-dpp TokenTransition; use wasm-dpp2",
|
|
178
|
+
)),
|
|
152
179
|
}
|
|
153
180
|
}
|
|
154
181
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
use dpp::consensus::basic::identity::ContractGroupBoundKeyNotAllowedInShieldedIdentityCreationError;
|
|
2
|
+
use dpp::consensus::codes::ErrorWithCode;
|
|
3
|
+
use dpp::consensus::ConsensusError;
|
|
4
|
+
|
|
5
|
+
use wasm_bindgen::prelude::*;
|
|
6
|
+
|
|
7
|
+
#[wasm_bindgen(js_name=ContractGroupBoundKeyNotAllowedInShieldedIdentityCreationError)]
|
|
8
|
+
pub struct ContractGroupBoundKeyNotAllowedInShieldedIdentityCreationErrorWasm {
|
|
9
|
+
inner: ContractGroupBoundKeyNotAllowedInShieldedIdentityCreationError,
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
impl From<&ContractGroupBoundKeyNotAllowedInShieldedIdentityCreationError>
|
|
13
|
+
for ContractGroupBoundKeyNotAllowedInShieldedIdentityCreationErrorWasm
|
|
14
|
+
{
|
|
15
|
+
fn from(e: &ContractGroupBoundKeyNotAllowedInShieldedIdentityCreationError) -> Self {
|
|
16
|
+
Self { inner: e.clone() }
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
#[wasm_bindgen(js_class=ContractGroupBoundKeyNotAllowedInShieldedIdentityCreationError)]
|
|
21
|
+
impl ContractGroupBoundKeyNotAllowedInShieldedIdentityCreationErrorWasm {
|
|
22
|
+
#[wasm_bindgen(js_name=getKeyId)]
|
|
23
|
+
pub fn get_key_id(&self) -> u32 {
|
|
24
|
+
self.inner.key_id()
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
#[wasm_bindgen(js_name=getCode)]
|
|
28
|
+
pub fn get_code(&self) -> u32 {
|
|
29
|
+
ConsensusError::from(self.inner.clone()).code()
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
#[wasm_bindgen(getter)]
|
|
33
|
+
pub fn message(&self) -> String {
|
|
34
|
+
self.inner.to_string()
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
mod contract_group_bound_key_not_allowed_in_shielded_identity_creation_error;
|
|
1
2
|
mod duplicated_identity_public_key_error;
|
|
2
3
|
mod duplicated_identity_public_key_id_error;
|
|
3
4
|
mod identity_asset_lock_proof_locked_transaction_mismatch_error;
|
|
@@ -28,6 +29,7 @@ mod missing_master_public_key_error;
|
|
|
28
29
|
mod missing_public_key_error;
|
|
29
30
|
mod not_implemented_credit_withdrawal_transition_pooling_error;
|
|
30
31
|
|
|
32
|
+
pub use contract_group_bound_key_not_allowed_in_shielded_identity_creation_error::*;
|
|
31
33
|
pub use duplicated_identity_public_key_error::*;
|
|
32
34
|
pub use duplicated_identity_public_key_id_error::*;
|
|
33
35
|
pub use identity_asset_lock_proof_locked_transaction_mismatch_error::*;
|