pshenmic-dpp 1.0.5 → 1.0.6
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/.github/workflows/build.yml +1 -1
- package/.github/workflows/publish.yml +1 -1
- package/Cargo.lock +147 -49
- package/Cargo.toml +13 -7
- package/README.md +10 -1
- package/dist/wasm/index.d.ts +52 -0
- package/dist/wasm/pshenmic_dpp.d.ts +962 -0
- package/dist/wasm/pshenmic_dpp.js +3342 -875
- package/dist/wasm/pshenmic_dpp_bg.js +1 -1
- package/dist/wasm/pshenmic_dpp_bg.wasm.d.ts +440 -0
- package/docs/AssetLockProof.md +107 -0
- package/docs/Building.md +50 -0
- package/docs/ChainLockProof.md +63 -0
- package/docs/CoreScript.md +17 -0
- package/docs/DataContract.md +192 -0
- package/docs/DataContractCreateTransition.md +84 -0
- package/docs/DataContractUpdateTransition.md +84 -0
- package/docs/Document.md +396 -0
- package/docs/DocumentBaseTransition.md +111 -0
- package/docs/DocumentCreateTransition.md +132 -0
- package/docs/DocumentDeleteTransition.md +82 -0
- package/docs/DocumentPurchaseTransition.md +109 -0
- package/docs/DocumentReplaceTransition.md +112 -0
- package/docs/DocumentTransferTransition.md +96 -0
- package/docs/DocumentTransition.md +125 -0
- package/docs/DocumentUpdatePriceTransition.md +109 -0
- package/docs/DocumentsBatch.md +133 -0
- package/docs/Enums.md +103 -0
- package/docs/Home.md +28 -0
- package/docs/Identifier.md +37 -0
- package/docs/Identity.md +140 -0
- package/docs/IdentityCreateTransition.md +155 -0
- package/docs/IdentityCreditTransfer.md +187 -0
- package/docs/IdentityCreditWithdrawalTransition.md +244 -0
- package/docs/IdentityPublicKey.md +348 -0
- package/docs/IdentityPublicKeyInCreation.md +141 -0
- package/docs/IdentityTopUpTransition.md +166 -0
- package/docs/IdentityUpdateTransition.md +234 -0
- package/docs/InstantAssetLockProof.md +117 -0
- package/docs/InstantLock.md +100 -0
- package/docs/OutPoint.md +80 -0
- package/docs/PrefundedVotingBalance.md +48 -0
- package/docs/PrivateKey.md +112 -0
- package/docs/TxOut.md +93 -0
- package/package.json +3 -3
- package/packages/asset_lock_proof/Cargo.toml +19 -0
- package/packages/asset_lock_proof/src/chain/mod.rs +79 -0
- package/packages/asset_lock_proof/src/instant/instant_lock.rs +111 -0
- package/packages/asset_lock_proof/src/instant/mod.rs +115 -0
- package/packages/asset_lock_proof/src/lib.rs +133 -0
- package/packages/asset_lock_proof/src/outpoint/mod.rs +79 -0
- package/packages/asset_lock_proof/src/tx_out/mod.rs +80 -0
- package/packages/cbor_conversation/Cargo.toml +1 -1
- package/packages/core_script/Cargo.toml +13 -0
- package/packages/core_script/src/lib.rs +69 -0
- package/packages/data_contract/Cargo.toml +2 -1
- package/packages/data_contract/src/lib.rs +34 -30
- package/packages/data_contract_transitions/Cargo.toml +1 -1
- package/packages/data_contract_transitions/src/create/mod.rs +3 -3
- package/packages/data_contract_transitions/src/update/mod.rs +3 -3
- package/packages/document/Cargo.toml +2 -1
- package/packages/document/src/lib.rs +13 -12
- package/packages/document/src/methods/mod.rs +41 -38
- package/packages/documents_batch/Cargo.toml +2 -1
- package/packages/documents_batch/src/document_base_transition/mod.rs +16 -20
- package/packages/documents_batch/src/document_transition/mod.rs +9 -9
- package/packages/documents_batch/src/lib.rs +23 -16
- package/packages/documents_batch/src/transitions/create/mod.rs +5 -2
- package/packages/documents_batch/src/transitions/transfer/mod.rs +9 -11
- package/packages/enums/Cargo.toml +1 -1
- package/packages/enums/src/batch/batch_enum.rs +2 -2
- package/packages/enums/src/lib.rs +2 -0
- package/packages/enums/src/lock_types/mod.rs +65 -0
- package/packages/enums/src/platform/mod.rs +2 -0
- package/packages/enums/src/withdrawal/mod.rs +72 -0
- package/packages/identifier/Cargo.toml +9 -0
- package/packages/identifier/src/lib.rs +105 -0
- package/packages/identity/Cargo.toml +2 -1
- package/packages/identity/src/lib.rs +13 -18
- package/packages/identity_public_key/Cargo.toml +1 -1
- package/packages/identity_transitions/Cargo.toml +7 -3
- package/packages/identity_transitions/src/create_transition/mod.rs +99 -36
- package/packages/identity_transitions/src/credit_withdrawal_transition/mod.rs +212 -0
- package/packages/identity_transitions/src/identity_credit_transfer_transition/mod.rs +169 -0
- package/packages/identity_transitions/src/lib.rs +6 -1
- package/packages/identity_transitions/src/{create_transition/public_key_in_creation → public_key_in_creation}/mod.rs +67 -20
- package/packages/identity_transitions/src/top_up_transition/mod.rs +141 -0
- package/packages/identity_transitions/src/update_transition/mod.rs +213 -0
- package/packages/private_key/Cargo.toml +1 -1
- package/packages/state_transition/Cargo.toml +2 -1
- package/packages/state_transition/src/lib.rs +3 -2
- package/packages/utils/Cargo.toml +2 -2
- package/packages/utils/src/lib.rs +0 -3
- package/scripts/build-js.sh +16 -0
- package/scripts/build.sh +5 -1
- package/src/lib.rs +1 -0
- package/tests/AssetLockProof.spec.js +80 -0
- package/tests/ChainLockProof.spec.js +69 -0
- package/tests/CoreScript.spec.js +37 -0
- package/tests/DataContract.spec.js +17 -14
- package/tests/Document.spec.js +14 -8
- package/tests/DocumentBatchTransition.spec.js +11 -11
- package/tests/DocumentTransition.spec.js +4 -4
- package/tests/DocumentsTransitions.spec.js +22 -22
- package/tests/Identifier.spec.js +84 -0
- package/tests/Identity.spec.js +1 -1
- package/tests/IdentityCreateTransition.spec.js +93 -0
- package/tests/IdentityCreditTransferTransition.spec.js +146 -0
- package/tests/IdentityCreditWithdrawalTransition.spec.js +192 -0
- package/tests/IdentityTopUpTransition.spec.js +131 -0
- package/tests/IdentityUpdateTransition.spec.js +147 -0
- package/tests/InstantLockProof.spec.js +97 -0
- package/tests/OutPoint.spec.js +55 -0
- package/tests/PublicKeyInCreation.spec.js +258 -0
- package/tests/TxOut.spec.js +76 -0
- package/tests/mocks/Locks/index.js +5 -0
- package/tests/mocks/PublicKey/index.js +1 -1
- package/typings/index.d.ts +52 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
use dpp::identifier::Identifier;
|
|
2
|
+
use dpp::identity::state_transition::{AssetLockProved, OptionallyAssetLockProved};
|
|
3
|
+
use dpp::prelude::UserFeeIncrease;
|
|
4
|
+
use dpp::serialization::{PlatformDeserializable, PlatformSerializable, Signable};
|
|
5
|
+
use dpp::state_transition::identity_topup_transition::IdentityTopUpTransition;
|
|
6
|
+
use dpp::state_transition::identity_topup_transition::accessors::IdentityTopUpTransitionAccessorsV0;
|
|
7
|
+
use dpp::state_transition::identity_topup_transition::v0::IdentityTopUpTransitionV0;
|
|
8
|
+
use dpp::state_transition::{StateTransition, StateTransitionLike};
|
|
9
|
+
use pshenmic_dpp_asset_lock_proof::AssetLockProofWASM;
|
|
10
|
+
use pshenmic_dpp_identifier::IdentifierWASM;
|
|
11
|
+
use pshenmic_dpp_state_transition::StateTransitionWASM;
|
|
12
|
+
use pshenmic_dpp_utils::WithJsError;
|
|
13
|
+
use wasm_bindgen::JsValue;
|
|
14
|
+
use wasm_bindgen::prelude::wasm_bindgen;
|
|
15
|
+
|
|
16
|
+
#[wasm_bindgen(js_name = "IdentityTopUpTransitionWASM")]
|
|
17
|
+
#[derive(Clone)]
|
|
18
|
+
pub struct IdentityTopUpTransitionWASM(IdentityTopUpTransition);
|
|
19
|
+
|
|
20
|
+
#[wasm_bindgen]
|
|
21
|
+
impl IdentityTopUpTransitionWASM {
|
|
22
|
+
#[wasm_bindgen(constructor)]
|
|
23
|
+
pub fn new(
|
|
24
|
+
asset_lock_proof: &AssetLockProofWASM,
|
|
25
|
+
js_identity_id: JsValue,
|
|
26
|
+
user_fee_increase: UserFeeIncrease,
|
|
27
|
+
) -> Result<IdentityTopUpTransitionWASM, JsValue> {
|
|
28
|
+
let identity_id: Identifier = IdentifierWASM::try_from(js_identity_id)?.into();
|
|
29
|
+
|
|
30
|
+
Ok(IdentityTopUpTransitionWASM(IdentityTopUpTransition::V0(
|
|
31
|
+
IdentityTopUpTransitionV0 {
|
|
32
|
+
asset_lock_proof: asset_lock_proof.clone().into(),
|
|
33
|
+
identity_id,
|
|
34
|
+
user_fee_increase,
|
|
35
|
+
signature: Default::default(),
|
|
36
|
+
},
|
|
37
|
+
)))
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
#[wasm_bindgen(js_name = "getModifiedDataIds")]
|
|
41
|
+
pub fn get_modified_data_ids(&self) -> Vec<IdentifierWASM> {
|
|
42
|
+
self.0
|
|
43
|
+
.modified_data_ids()
|
|
44
|
+
.iter()
|
|
45
|
+
.map(|id| id.clone().into())
|
|
46
|
+
.collect()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
#[wasm_bindgen(js_name = "getOptionalAssetLockProof")]
|
|
50
|
+
pub fn get_optional_asset_lock_proof(&self) -> JsValue {
|
|
51
|
+
match self.0.optional_asset_lock_proof() {
|
|
52
|
+
Some(asset_lock) => JsValue::from(AssetLockProofWASM::from(asset_lock.clone())),
|
|
53
|
+
None => JsValue::null(),
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
#[wasm_bindgen(getter = "userFeeIncrease")]
|
|
58
|
+
pub fn get_user_fee_increase(&self) -> UserFeeIncrease {
|
|
59
|
+
self.0.user_fee_increase()
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
#[wasm_bindgen(getter = "identityIdentifier")]
|
|
63
|
+
pub fn get_identity_identifier(&self) -> IdentifierWASM {
|
|
64
|
+
self.0.identity_id().clone().into()
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
#[wasm_bindgen(getter = "assetLockProof")]
|
|
68
|
+
pub fn get_asset_lock_proof(&self) -> AssetLockProofWASM {
|
|
69
|
+
self.0.asset_lock_proof().clone().into()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
#[wasm_bindgen(setter = "userFeeIncrease")]
|
|
73
|
+
pub fn set_user_fee_increase(&mut self, user_fee_increase: UserFeeIncrease) {
|
|
74
|
+
self.0.set_user_fee_increase(user_fee_increase);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
#[wasm_bindgen(setter = "identityIdentifier")]
|
|
78
|
+
pub fn set_identity_identifier(
|
|
79
|
+
&mut self,
|
|
80
|
+
js_identity_identifier: &JsValue,
|
|
81
|
+
) -> Result<(), JsValue> {
|
|
82
|
+
let identity_identifier: Identifier =
|
|
83
|
+
IdentifierWASM::try_from(js_identity_identifier)?.into();
|
|
84
|
+
Ok(self.0.set_identity_id(identity_identifier.clone().into()))
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
#[wasm_bindgen(setter = "assetLockProof")]
|
|
88
|
+
pub fn set_asset_lock_proof(
|
|
89
|
+
&mut self,
|
|
90
|
+
asset_lock_proof: &AssetLockProofWASM,
|
|
91
|
+
) -> Result<(), JsValue> {
|
|
92
|
+
self.0
|
|
93
|
+
.set_asset_lock_proof(asset_lock_proof.clone().into())
|
|
94
|
+
.with_js_error()
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
#[wasm_bindgen(getter = "signature")]
|
|
98
|
+
pub fn get_signature(&self) -> Vec<u8> {
|
|
99
|
+
self.0.signature().to_vec()
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
#[wasm_bindgen(js_name = "getSignableBytes")]
|
|
103
|
+
pub fn get_signable_bytes(&self) -> Result<Vec<u8>, JsValue> {
|
|
104
|
+
self.0.signable_bytes().with_js_error()
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
#[wasm_bindgen(setter = "signature")]
|
|
108
|
+
pub fn set_signature(&mut self, signature: Vec<u8>) {
|
|
109
|
+
self.0.set_signature_bytes(signature)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
#[wasm_bindgen(js_name = "toBytes")]
|
|
113
|
+
pub fn to_bytes(&self) -> Result<Vec<u8>, JsValue> {
|
|
114
|
+
self.0.serialize_to_bytes().with_js_error()
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
#[wasm_bindgen(js_name = "fromBytes")]
|
|
118
|
+
pub fn from_bytes(bytes: Vec<u8>) -> Result<IdentityTopUpTransitionWASM, JsValue> {
|
|
119
|
+
let rs_transition =
|
|
120
|
+
IdentityTopUpTransition::deserialize_from_bytes(bytes.as_slice()).with_js_error()?;
|
|
121
|
+
|
|
122
|
+
Ok(IdentityTopUpTransitionWASM(rs_transition))
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
#[wasm_bindgen(js_name = "toStateTransition")]
|
|
126
|
+
pub fn to_state_transition(&self) -> StateTransitionWASM {
|
|
127
|
+
StateTransitionWASM::from(StateTransition::from(self.0.clone()))
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
#[wasm_bindgen(js_name = "fromStateTransition")]
|
|
131
|
+
pub fn from_state_transition(
|
|
132
|
+
st: StateTransitionWASM,
|
|
133
|
+
) -> Result<IdentityTopUpTransitionWASM, JsValue> {
|
|
134
|
+
let rs_st: StateTransition = st.into();
|
|
135
|
+
|
|
136
|
+
match rs_st {
|
|
137
|
+
StateTransition::IdentityTopUp(st) => Ok(IdentityTopUpTransitionWASM(st)),
|
|
138
|
+
_ => Err(JsValue::from_str(&"Invalid state transition type)")),
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
use crate::public_key_in_creation::IdentityPublicKeyInCreationWASM;
|
|
2
|
+
use dpp::identity::KeyID;
|
|
3
|
+
use dpp::identity::state_transition::OptionallyAssetLockProved;
|
|
4
|
+
use dpp::prelude::{IdentityNonce, Revision, UserFeeIncrease};
|
|
5
|
+
use dpp::serialization::{PlatformDeserializable, PlatformSerializable, Signable};
|
|
6
|
+
use dpp::state_transition::identity_update_transition::IdentityUpdateTransition;
|
|
7
|
+
use dpp::state_transition::identity_update_transition::accessors::IdentityUpdateTransitionAccessorsV0;
|
|
8
|
+
use dpp::state_transition::identity_update_transition::v0::IdentityUpdateTransitionV0;
|
|
9
|
+
use dpp::state_transition::public_key_in_creation::IdentityPublicKeyInCreation;
|
|
10
|
+
use dpp::state_transition::{StateTransition, StateTransitionIdentitySigned, StateTransitionLike};
|
|
11
|
+
use pshenmic_dpp_asset_lock_proof::AssetLockProofWASM;
|
|
12
|
+
use pshenmic_dpp_enums::keys::purpose::PurposeWASM;
|
|
13
|
+
use pshenmic_dpp_identifier::IdentifierWASM;
|
|
14
|
+
use pshenmic_dpp_state_transition::StateTransitionWASM;
|
|
15
|
+
use pshenmic_dpp_utils::WithJsError;
|
|
16
|
+
use wasm_bindgen::JsValue;
|
|
17
|
+
use wasm_bindgen::prelude::wasm_bindgen;
|
|
18
|
+
|
|
19
|
+
#[wasm_bindgen(js_name = "IdentityUpdateTransitionWASM")]
|
|
20
|
+
#[derive(Clone)]
|
|
21
|
+
pub struct IdentityUpdateTransitionWASM(IdentityUpdateTransition);
|
|
22
|
+
|
|
23
|
+
#[wasm_bindgen]
|
|
24
|
+
impl IdentityUpdateTransitionWASM {
|
|
25
|
+
#[wasm_bindgen(constructor)]
|
|
26
|
+
pub fn new(
|
|
27
|
+
js_identity_id: &JsValue,
|
|
28
|
+
revision: Revision,
|
|
29
|
+
nonce: IdentityNonce,
|
|
30
|
+
user_fee_increase: Option<UserFeeIncrease>,
|
|
31
|
+
js_add_public_keys: &js_sys::Array,
|
|
32
|
+
disable_public_keys: Vec<KeyID>,
|
|
33
|
+
) -> Result<IdentityUpdateTransitionWASM, JsValue> {
|
|
34
|
+
let identity_id = IdentifierWASM::try_from(js_identity_id)?;
|
|
35
|
+
|
|
36
|
+
let add_public_keys: Vec<IdentityPublicKeyInCreationWASM> =
|
|
37
|
+
IdentityPublicKeyInCreationWASM::vec_from_js_value(js_add_public_keys)?;
|
|
38
|
+
|
|
39
|
+
Ok(IdentityUpdateTransitionWASM(IdentityUpdateTransition::V0(
|
|
40
|
+
IdentityUpdateTransitionV0 {
|
|
41
|
+
identity_id: identity_id.into(),
|
|
42
|
+
revision,
|
|
43
|
+
nonce,
|
|
44
|
+
add_public_keys: add_public_keys
|
|
45
|
+
.clone()
|
|
46
|
+
.iter()
|
|
47
|
+
.map(|key| key.clone().into())
|
|
48
|
+
.collect(),
|
|
49
|
+
disable_public_keys,
|
|
50
|
+
user_fee_increase: user_fee_increase.unwrap_or(0),
|
|
51
|
+
signature_public_key_id: 0,
|
|
52
|
+
signature: Default::default(),
|
|
53
|
+
},
|
|
54
|
+
)))
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
#[wasm_bindgen(getter = "revision")]
|
|
58
|
+
pub fn get_revision(&self) -> Revision {
|
|
59
|
+
self.0.revision()
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
#[wasm_bindgen(getter = "nonce")]
|
|
63
|
+
pub fn get_nonce(&self) -> IdentityNonce {
|
|
64
|
+
self.0.nonce()
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
#[wasm_bindgen(getter = "identityIdentifier")]
|
|
68
|
+
pub fn get_identity_identifier(&self) -> IdentifierWASM {
|
|
69
|
+
self.0.identity_id().into()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
#[wasm_bindgen(js_name = "getPurposeRequirement")]
|
|
73
|
+
pub fn get_purpose_requirement(&self) -> Vec<String> {
|
|
74
|
+
self.0
|
|
75
|
+
.purpose_requirement()
|
|
76
|
+
.iter()
|
|
77
|
+
.map(|purpose| PurposeWASM::from(purpose.clone()).into())
|
|
78
|
+
.collect()
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
#[wasm_bindgen(js_name = "getModifiedDataIds")]
|
|
82
|
+
pub fn get_modified_data_ids(&self) -> Vec<IdentifierWASM> {
|
|
83
|
+
self.0
|
|
84
|
+
.modified_data_ids()
|
|
85
|
+
.iter()
|
|
86
|
+
.map(|id| id.clone().into())
|
|
87
|
+
.collect()
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
#[wasm_bindgen(js_name = "getOptionalAssetLockProof")]
|
|
91
|
+
pub fn get_optional_asset_lock_proof(&self) -> JsValue {
|
|
92
|
+
match self.0.optional_asset_lock_proof() {
|
|
93
|
+
Some(asset_lock) => JsValue::from(AssetLockProofWASM::from(asset_lock.clone())),
|
|
94
|
+
None => JsValue::null(),
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
#[wasm_bindgen(getter = "publicKeyIdsToDisable")]
|
|
99
|
+
pub fn get_public_key_ids_to_disable(&self) -> Vec<KeyID> {
|
|
100
|
+
self.0.public_key_ids_to_disable().to_vec()
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
#[wasm_bindgen(getter = "publicKeyIdsToAdd")]
|
|
104
|
+
pub fn get_public_key_ids_to_add(&self) -> Vec<IdentityPublicKeyInCreationWASM> {
|
|
105
|
+
self.0
|
|
106
|
+
.public_keys_to_add()
|
|
107
|
+
.to_vec()
|
|
108
|
+
.iter()
|
|
109
|
+
.map(|id| id.clone().into())
|
|
110
|
+
.collect()
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
#[wasm_bindgen(getter = "userFeeIncrease")]
|
|
114
|
+
pub fn get_user_fee_increase(&self) -> UserFeeIncrease {
|
|
115
|
+
self.0.user_fee_increase()
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
#[wasm_bindgen(setter = "revision")]
|
|
119
|
+
pub fn set_revision(&mut self, revision: Revision) {
|
|
120
|
+
self.0.set_revision(revision);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
#[wasm_bindgen(setter = "nonce")]
|
|
124
|
+
pub fn set_nonce(&mut self, nonce: IdentityNonce) {
|
|
125
|
+
self.0.set_nonce(nonce);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
#[wasm_bindgen(setter = "identityIdentifier")]
|
|
129
|
+
pub fn set_identity_identifier(&mut self, js_identity_id: &JsValue) -> Result<(), JsValue> {
|
|
130
|
+
let identity_id = IdentifierWASM::try_from(js_identity_id)?;
|
|
131
|
+
self.0.set_identity_id(identity_id.clone().into());
|
|
132
|
+
Ok(())
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
#[wasm_bindgen(setter = "publicKeyIdsToAdd")]
|
|
136
|
+
pub fn set_public_key_ids_to_add(
|
|
137
|
+
&mut self,
|
|
138
|
+
js_add_public_keys: &js_sys::Array,
|
|
139
|
+
) -> Result<(), JsValue> {
|
|
140
|
+
let add_public_keys: Vec<IdentityPublicKeyInCreationWASM> =
|
|
141
|
+
IdentityPublicKeyInCreationWASM::vec_from_js_value(js_add_public_keys)?;
|
|
142
|
+
|
|
143
|
+
let keys: Vec<IdentityPublicKeyInCreation> =
|
|
144
|
+
add_public_keys.iter().map(|id| id.clone().into()).collect();
|
|
145
|
+
|
|
146
|
+
Ok(self.0.set_public_keys_to_add(keys))
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
#[wasm_bindgen(setter = "publicKeyIdsToDisable")]
|
|
150
|
+
pub fn set_public_key_ids_to_disable(&mut self, public_keys: Vec<KeyID>) {
|
|
151
|
+
self.0.set_public_key_ids_to_disable(public_keys)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
#[wasm_bindgen(setter = "userFeeIncrease")]
|
|
155
|
+
pub fn set_user_fee_increase(&mut self, user_fee_increase: UserFeeIncrease) {
|
|
156
|
+
self.0.set_user_fee_increase(user_fee_increase)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
#[wasm_bindgen(getter = "signature")]
|
|
160
|
+
pub fn get_signature(&self) -> Vec<u8> {
|
|
161
|
+
self.0.signature().to_vec()
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
#[wasm_bindgen(js_name = "getSignableBytes")]
|
|
165
|
+
pub fn get_signable_bytes(&self) -> Result<Vec<u8>, JsValue> {
|
|
166
|
+
self.0.signable_bytes().with_js_error()
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
#[wasm_bindgen(getter = "signaturePublicKeyId")]
|
|
170
|
+
pub fn get_signature_public_key_id(&self) -> KeyID {
|
|
171
|
+
self.0.signature_public_key_id()
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
#[wasm_bindgen(setter = "signature")]
|
|
175
|
+
pub fn set_signature(&mut self, signature: Vec<u8>) {
|
|
176
|
+
self.0.set_signature_bytes(signature)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
#[wasm_bindgen(setter = "signaturePublicKeyId")]
|
|
180
|
+
pub fn set_signature_public_key_id(&mut self, signature_public_key_id: KeyID) {
|
|
181
|
+
self.0.set_signature_public_key_id(signature_public_key_id)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
#[wasm_bindgen(js_name = "toBytes")]
|
|
185
|
+
pub fn to_bytes(&self) -> Result<Vec<u8>, JsValue> {
|
|
186
|
+
self.0.serialize_to_bytes().with_js_error()
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
#[wasm_bindgen(js_name = "fromBytes")]
|
|
190
|
+
pub fn from_bytes(bytes: Vec<u8>) -> Result<IdentityUpdateTransitionWASM, JsValue> {
|
|
191
|
+
let rs_transition =
|
|
192
|
+
IdentityUpdateTransition::deserialize_from_bytes(bytes.as_slice()).with_js_error()?;
|
|
193
|
+
|
|
194
|
+
Ok(IdentityUpdateTransitionWASM(rs_transition))
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
#[wasm_bindgen(js_name = "toStateTransition")]
|
|
198
|
+
pub fn to_state_transition(&self) -> StateTransitionWASM {
|
|
199
|
+
StateTransitionWASM::from(StateTransition::from(self.0.clone()))
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
#[wasm_bindgen(js_name = "fromStateTransition")]
|
|
203
|
+
pub fn from_state_transition(
|
|
204
|
+
st: StateTransitionWASM,
|
|
205
|
+
) -> Result<IdentityUpdateTransitionWASM, JsValue> {
|
|
206
|
+
let rs_st: StateTransition = st.into();
|
|
207
|
+
|
|
208
|
+
match rs_st {
|
|
209
|
+
StateTransition::IdentityUpdate(st) => Ok(IdentityUpdateTransitionWASM(st)),
|
|
210
|
+
_ => Err(JsValue::from_str(&"Invalid state transition type)")),
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
@@ -7,7 +7,7 @@ edition = "2024"
|
|
|
7
7
|
crate-type = ["cdylib", "lib"]
|
|
8
8
|
|
|
9
9
|
[dependencies]
|
|
10
|
-
wasm-bindgen = { version = "=0.2.100", features = ["serde-serialize"] }
|
|
10
|
+
wasm-bindgen = { version = "=0.2.100", default-features = false, features = ["serde-serialize"] }
|
|
11
11
|
dpp = { git = "https://github.com/dashpay/platform", branch = "master", default-features = false, features = [
|
|
12
12
|
"identity-value-conversion",
|
|
13
13
|
]}
|
|
@@ -7,10 +7,11 @@ edition = "2024"
|
|
|
7
7
|
crate-type = ["cdylib", "lib"]
|
|
8
8
|
|
|
9
9
|
[dependencies]
|
|
10
|
-
wasm-bindgen = { version = "=0.2.100", features = ["serde-serialize"]
|
|
10
|
+
wasm-bindgen = { version = "=0.2.100", default-features = false, features = ["serde-serialize"] }
|
|
11
11
|
pshenmic_dpp_public_key = {path = "../identity_public_key" }
|
|
12
12
|
pshenmic_dpp_private_key = {path = "../private_key"}
|
|
13
13
|
pshenmic_dpp_utils = {path = "../utils"}
|
|
14
|
+
pshenmic_dpp_identifier = {path = "../identifier"}
|
|
14
15
|
pshenmic_dpp_mock_bls = {path = "../mock_bls"}
|
|
15
16
|
pshenmic_dpp_enums = {path = "../enums"}
|
|
16
17
|
dpp = { git = "https://github.com/dashpay/platform", branch = "master", default-features = false, features = [
|
|
@@ -7,6 +7,7 @@ use dpp::serialization::{PlatformDeserializable, PlatformSerializable, Signable}
|
|
|
7
7
|
use dpp::state_transition::StateTransition;
|
|
8
8
|
use pshenmic_dpp_enums::keys::key_type::KeyTypeWASM;
|
|
9
9
|
use pshenmic_dpp_enums::keys::purpose::PurposeWASM;
|
|
10
|
+
use pshenmic_dpp_identifier::IdentifierWASM;
|
|
10
11
|
use pshenmic_dpp_mock_bls::MockBLS;
|
|
11
12
|
use pshenmic_dpp_private_key::PrivateKeyWASM;
|
|
12
13
|
use pshenmic_dpp_public_key::IdentityPublicKeyWASM;
|
|
@@ -111,8 +112,8 @@ impl StateTransitionWASM {
|
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
#[wasm_bindgen(js_name = "getOwnerId")]
|
|
114
|
-
pub fn get_owner_id(&self) ->
|
|
115
|
-
self.0.owner_id().
|
|
115
|
+
pub fn get_owner_id(&self) -> IdentifierWASM {
|
|
116
|
+
self.0.owner_id().into()
|
|
116
117
|
}
|
|
117
118
|
|
|
118
119
|
#[wasm_bindgen(getter = "signature")]
|
|
@@ -7,12 +7,12 @@ edition = "2024"
|
|
|
7
7
|
crate-type = ["cdylib", "lib"]
|
|
8
8
|
|
|
9
9
|
[dependencies]
|
|
10
|
-
wasm-bindgen = { version = "=0.2.100", features = ["serde-serialize"] }
|
|
10
|
+
wasm-bindgen = { version = "=0.2.100", default-features = false, features = ["serde-serialize"] }
|
|
11
11
|
anyhow = { version = "1.0.75" }
|
|
12
12
|
dpp = { git = "https://github.com/dashpay/platform", branch = "master", features = [
|
|
13
13
|
"platform-value",
|
|
14
14
|
"document-json-conversion"
|
|
15
|
-
]}
|
|
15
|
+
] }
|
|
16
16
|
js-sys = "0.3.53"
|
|
17
17
|
serde_json = { version = "1.0", features = ["preserve_order"] }
|
|
18
18
|
serde-wasm-bindgen = { git = "https://github.com/QuantumExplorer/serde-wasm-bindgen", branch = "feat/not_human_readable" }
|
|
@@ -221,9 +221,6 @@ pub fn get_bool_from_options(
|
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
#[allow(dead_code)]
|
|
225
|
-
#[deprecated(note = "This function is marked as unused.")]
|
|
226
|
-
#[allow(deprecated)]
|
|
227
224
|
pub fn get_class_name(value: &JsValue) -> String {
|
|
228
225
|
js_sys::Object::get_prototype_of(value)
|
|
229
226
|
.constructor()
|
package/scripts/build-js.sh
CHANGED
|
@@ -6,11 +6,18 @@ DIST_WASM_DIR="$DIST_DIR/wasm"
|
|
|
6
6
|
DIST_WASM_BINARY_BASE_64="$DIST_WASM_DIR/pshenmic_dpp_bg.js"
|
|
7
7
|
DIST_WASM_BINARY_RAW="$DIST_WASM_DIR/pshenmic_dpp_bg.wasm"
|
|
8
8
|
DIST_WASM_JS="$DIST_WASM_DIR/pshenmic_dpp.js"
|
|
9
|
+
DIST_WASM_TS_BG="$DIST_WASM_DIR/pshenmic_dpp_bg.wasm.d.ts"
|
|
10
|
+
DIST_WASM_TS="$DIST_WASM_DIR/pshenmic_dpp.d.ts"
|
|
11
|
+
DIST_WASM_TS_INDEX="$DIST_WASM_DIR/index.d.ts"
|
|
12
|
+
|
|
9
13
|
|
|
10
14
|
## Paths to wasm files produced by wasm-bindgen
|
|
11
15
|
WASM_DIR="$PWD/wasm"
|
|
12
16
|
WASM_JS_CODE_PATH="$WASM_DIR/pshenmic_dpp.js"
|
|
13
17
|
WASM_BINARY_PATH="$WASM_DIR/pshenmic_dpp_bg.wasm"
|
|
18
|
+
WASM_TS_BG_CODE_PATH="$WASM_DIR/pshenmic_dpp_bg.wasm.d.ts"
|
|
19
|
+
WASM_TS_CODE_PATH="$WASM_DIR/pshenmic_dpp.d.ts"
|
|
20
|
+
WASM_TS_INDEX_CODE_PATH="$PWD/typings/index.d.ts"
|
|
14
21
|
|
|
15
22
|
# Create directory in dist to save transpiled wasm code and TS typings
|
|
16
23
|
mkdir -p $DIST_WASM_DIR
|
|
@@ -20,6 +27,10 @@ rm -rf $DIST_WASM_BINARY_BASE_64
|
|
|
20
27
|
rm -rf $DIST_WASM_BINARY_RAW
|
|
21
28
|
rm -rf $DIST_WASM_JS
|
|
22
29
|
|
|
30
|
+
rm -rf $DIST_WASM_TS_INDEX
|
|
31
|
+
rm -rf $DIST_WASM_TS_BG
|
|
32
|
+
rm -rf $DIST_WASM_TS
|
|
33
|
+
|
|
23
34
|
## Converting wasm into base64 and saving it to dist folder
|
|
24
35
|
|
|
25
36
|
if [[ "${RAW}" == "true" ]]; then
|
|
@@ -33,6 +44,11 @@ fi
|
|
|
33
44
|
echo "Copying ES module to dist"
|
|
34
45
|
cp $WASM_JS_CODE_PATH $DIST_WASM_JS
|
|
35
46
|
|
|
47
|
+
echo "Copying TS types to dist"
|
|
48
|
+
cp $WASM_TS_INDEX_CODE_PATH $DIST_WASM_TS_INDEX
|
|
49
|
+
cp $WASM_TS_BG_CODE_PATH $DIST_WASM_TS_BG
|
|
50
|
+
cp $WASM_TS_CODE_PATH $DIST_WASM_TS
|
|
51
|
+
|
|
36
52
|
echo "Cleaning wasm build"
|
|
37
53
|
rm -rf $WASM_DIR
|
|
38
54
|
|
package/scripts/build.sh
CHANGED
|
@@ -12,7 +12,8 @@ OUTPUT_FILE="${PWD}/wasm/pshenmic_dpp_bg.wasm"
|
|
|
12
12
|
RUSTFLAGS="-C target-feature=+crt-static -C embed-bitcode=no -C metadata=reduced -C link-dead-code=no -C panic=abort"
|
|
13
13
|
|
|
14
14
|
BUILD_COMMAND="cargo build --config net.git-fetch-with-cli=true --target=${TARGET} ${PROFILE_ARG}"
|
|
15
|
-
|
|
15
|
+
STRIP_COMMAND=" wasm-snip ${PWD}/target/${TARGET}/${PROFILE}/pshenmic_dpp.wasm -o ${PWD}/target/${TARGET}/${PROFILE}/pshenmic_dpp.wasm --snip-rust-fmt-code --snip-rust-panicking-code"
|
|
16
|
+
BINDGEN_COMMAND="wasm-bindgen --typescript --out-dir=${OUTPUT_DIR} --target=web --omit-default-module-path ${PWD}/target/${TARGET}/${PROFILE}/pshenmic_dpp.wasm"
|
|
16
17
|
|
|
17
18
|
if ! [[ -d ${OUTPUT_DIR} ]]; then
|
|
18
19
|
mkdir -p "${OUTPUT_DIR}"
|
|
@@ -25,6 +26,7 @@ if [[ "${OSTYPE}" == "darwin"* ]]; then
|
|
|
25
26
|
AR=${AR_PATH} CC=${CLANG_PATH} ${BINDGEN_COMMAND}
|
|
26
27
|
else
|
|
27
28
|
${BUILD_COMMAND}
|
|
29
|
+
${STRIP_COMMAND}
|
|
28
30
|
${BINDGEN_COMMAND}
|
|
29
31
|
fi
|
|
30
32
|
|
|
@@ -32,6 +34,8 @@ if command -v wasm-opt &> /dev/null; then
|
|
|
32
34
|
echo "Optimizing wasm using Binaryen"
|
|
33
35
|
wasm-opt \
|
|
34
36
|
--generate-global-effects \
|
|
37
|
+
--enable-bulk-memory \
|
|
38
|
+
--enable-nontrapping-float-to-int \
|
|
35
39
|
-Oz \
|
|
36
40
|
-tnh \
|
|
37
41
|
--flatten \
|
package/src/lib.rs
CHANGED
|
@@ -12,6 +12,7 @@ pub use pshenmic_dpp_data_contract_transitions;
|
|
|
12
12
|
pub use pshenmic_dpp_document_search;
|
|
13
13
|
pub use pshenmic_dpp_documents_batch;
|
|
14
14
|
pub use pshenmic_dpp_enums;
|
|
15
|
+
pub use pshenmic_dpp_identifier;
|
|
15
16
|
pub use pshenmic_dpp_identity;
|
|
16
17
|
pub use pshenmic_dpp_identity_transitions;
|
|
17
18
|
pub use pshenmic_dpp_state_transition;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const assert = require('assert')
|
|
2
|
+
const { describe, it, before } = require('mocha')
|
|
3
|
+
const initWasm = require('./utils/wasm')
|
|
4
|
+
const { instantLockBytes, transactionBytes } = require('./mocks/Locks')
|
|
5
|
+
|
|
6
|
+
let wasm
|
|
7
|
+
|
|
8
|
+
describe('AssetLockProof', function () {
|
|
9
|
+
before(async function () {
|
|
10
|
+
wasm = initWasm()
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
describe('serialization / deserialization', function () {
|
|
14
|
+
it('should allow to get instant lock proof via constructor', () => {
|
|
15
|
+
const instantLockProof = new wasm.AssetLockProofWASM('instant')
|
|
16
|
+
|
|
17
|
+
assert.equal(instantLockProof.constructor.name, 'AssetLockProofWASM')
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it('shouldn\'t allow to get chain lock proof via constructor', () => {
|
|
21
|
+
try {
|
|
22
|
+
new wasm.AssetLockProofWASM('chain')
|
|
23
|
+
} catch (e) {
|
|
24
|
+
assert.ok(true)
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
assert.ok()
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it('should allow to create instant lock proof from values', () => {
|
|
31
|
+
const instantLockProof = wasm.AssetLockProofWASM.createInstantAssetLockProof(instantLockBytes, transactionBytes, 0)
|
|
32
|
+
|
|
33
|
+
assert.equal(instantLockProof.constructor.name, 'AssetLockProofWASM')
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('should allow to create chain lock proof from values', () => {
|
|
37
|
+
const outpoint = new wasm.OutPointWASM('e8b43025641eea4fd21190f01bd870ef90f1a8b199d8fc3376c5b62c0b1a179d', 1)
|
|
38
|
+
|
|
39
|
+
const chainLockProof = wasm.AssetLockProofWASM.createChainAssetLockProof(1, outpoint)
|
|
40
|
+
|
|
41
|
+
assert.equal(chainLockProof.constructor.name, 'AssetLockProofWASM')
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
describe('getters', function () {
|
|
46
|
+
it('should allow to get lock type', () => {
|
|
47
|
+
const outpoint = new wasm.OutPointWASM('e8b43025641eea4fd21190f01bd870ef90f1a8b199d8fc3376c5b62c0b1a179d', 1)
|
|
48
|
+
|
|
49
|
+
const chainLockProof = wasm.AssetLockProofWASM.createChainAssetLockProof(1, outpoint)
|
|
50
|
+
|
|
51
|
+
const instantLockProof = new wasm.AssetLockProofWASM('instant')
|
|
52
|
+
|
|
53
|
+
assert.equal(chainLockProof.getLockType(), 'Chain')
|
|
54
|
+
assert.equal(instantLockProof.getLockType(), 'Instant')
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('should allow to get lock instances', () => {
|
|
58
|
+
const outpoint = new wasm.OutPointWASM('e8b43025641eea4fd21190f01bd870ef90f1a8b199d8fc3376c5b62c0b1a179d', 1)
|
|
59
|
+
|
|
60
|
+
const chainLockProof = wasm.AssetLockProofWASM.createChainAssetLockProof(1, outpoint)
|
|
61
|
+
|
|
62
|
+
const instantLockProof = new wasm.AssetLockProofWASM('instant')
|
|
63
|
+
|
|
64
|
+
assert.equal(chainLockProof.getChainLockProof().constructor.name, 'ChainAssetLockProofWASM')
|
|
65
|
+
assert.equal(instantLockProof.getInstantLockProof().constructor.name, 'InstantAssetLockProofWASM')
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it('should allow to return object of lock', () => {
|
|
69
|
+
const instantLockProof = new wasm.AssetLockProofWASM('instant')
|
|
70
|
+
|
|
71
|
+
const expected = {
|
|
72
|
+
instantLock: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
73
|
+
transaction: [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 1, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0],
|
|
74
|
+
outputIndex: 0
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
assert.deepEqual(instantLockProof.toObject(), expected)
|
|
78
|
+
})
|
|
79
|
+
})
|
|
80
|
+
})
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const assert = require('assert')
|
|
2
|
+
const { describe, it, before } = require('mocha')
|
|
3
|
+
const initWasm = require('./utils/wasm')
|
|
4
|
+
|
|
5
|
+
let wasm
|
|
6
|
+
|
|
7
|
+
describe('InstantLock', function () {
|
|
8
|
+
before(async function () {
|
|
9
|
+
wasm = initWasm()
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
describe('serialization / deserialization', function () {
|
|
13
|
+
it('should allow to create chain lock proof from values', () => {
|
|
14
|
+
const outpoint = new wasm.OutPointWASM('e8b43025641eea4fd21190f01bd870ef90f1a8b199d8fc3376c5b62c0b1a179d', 1)
|
|
15
|
+
const chainlock = new wasm.ChainAssetLockProofWASM(11, outpoint)
|
|
16
|
+
|
|
17
|
+
assert.notEqual(chainlock.__wbg_ptr, 0)
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it('should allow to create chain lock proof from object', () => {
|
|
21
|
+
const outpoint = new wasm.OutPointWASM('e8b43025641eea4fd21190f01bd870ef90f1a8b199d8fc3376c5b62c0b1a179d', 1)
|
|
22
|
+
const chainlock = wasm.ChainAssetLockProofWASM.fromRawObject({
|
|
23
|
+
coreChainLockedHeight: 11,
|
|
24
|
+
outPoint: Array.from(outpoint.toBytes())
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
assert.notEqual(chainlock.__wbg_ptr, 0)
|
|
28
|
+
})
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
describe('getters', function () {
|
|
32
|
+
it('should allow to get coreChainLockedHeight', () => {
|
|
33
|
+
const outpoint = new wasm.OutPointWASM('e8b43025641eea4fd21190f01bd870ef90f1a8b199d8fc3376c5b62c0b1a179d', 1)
|
|
34
|
+
const chainlock = new wasm.ChainAssetLockProofWASM(11, outpoint)
|
|
35
|
+
|
|
36
|
+
assert.equal(chainlock.coreChainLockedHeight, 11)
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it('should allow to get outPoint', () => {
|
|
40
|
+
const outpoint = new wasm.OutPointWASM('e8b43025641eea4fd21190f01bd870ef90f1a8b199d8fc3376c5b62c0b1a179d', 1)
|
|
41
|
+
const chainlock = new wasm.ChainAssetLockProofWASM(11, outpoint)
|
|
42
|
+
|
|
43
|
+
assert.equal(chainlock.outPoint.constructor.name, 'OutPointWASM')
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
describe('setters', function () {
|
|
48
|
+
it('should allow to set coreChainLockedHeight', () => {
|
|
49
|
+
const outpoint = new wasm.OutPointWASM('e8b43025641eea4fd21190f01bd870ef90f1a8b199d8fc3376c5b62c0b1a179d', 1)
|
|
50
|
+
const chainlock = new wasm.ChainAssetLockProofWASM(11, outpoint)
|
|
51
|
+
|
|
52
|
+
chainlock.coreChainLockedHeight = 33
|
|
53
|
+
|
|
54
|
+
assert.equal(chainlock.coreChainLockedHeight, 33)
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('should allow to get outPoint', () => {
|
|
58
|
+
const outpoint = new wasm.OutPointWASM('e8b43025641eea4fd21190f01bd870ef90f1a8b199d8fc3376c5b62c0b1a179d', 1)
|
|
59
|
+
const chainlock = new wasm.ChainAssetLockProofWASM(11, outpoint)
|
|
60
|
+
|
|
61
|
+
const newOutpoint = new wasm.OutPointWASM('e8b43025641eea4fd21190f01bd870ef90f1a8b199d8fc3376c5b62c0b1a179d', 222)
|
|
62
|
+
|
|
63
|
+
chainlock.outPoint = newOutpoint
|
|
64
|
+
|
|
65
|
+
assert.equal(chainlock.outPoint.getVOUT(), 222)
|
|
66
|
+
assert.notEqual(newOutpoint.__wbg_ptr, 0)
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
})
|