From b7d8afcc192105fa9780094f611f31bd95fa888f Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Fri, 20 Oct 2023 11:01:24 +0700 Subject: [PATCH] chore: remove asset lock proof type --- .../chain/chain_asset_lock_proof.rs | 10 ---------- .../instant/instant_asset_lock_proof.rs | 15 +-------------- .../chain/chain_asset_lock_proof.rs | 5 ----- .../instant/instant_asset_lock_proof.rs | 5 ----- .../assetLockProof/ChainAssetLockProof.spec.js | 7 ------- 5 files changed, 1 insertion(+), 41 deletions(-) diff --git a/packages/rs-dpp/src/identity/state_transition/asset_lock_proof/chain/chain_asset_lock_proof.rs b/packages/rs-dpp/src/identity/state_transition/asset_lock_proof/chain/chain_asset_lock_proof.rs index 6d1fc03ea85..aa0a4d348f4 100644 --- a/packages/rs-dpp/src/identity/state_transition/asset_lock_proof/chain/chain_asset_lock_proof.rs +++ b/packages/rs-dpp/src/identity/state_transition/asset_lock_proof/chain/chain_asset_lock_proof.rs @@ -12,9 +12,6 @@ use dashcore::OutPoint; #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct ChainAssetLockProof { - // TODO: Remove type - #[serde(rename = "type")] - asset_lock_type: u8, pub core_chain_locked_height: u32, pub out_point: OutPoint, } @@ -36,18 +33,11 @@ impl ChainAssetLockProof { pub fn new(core_chain_locked_height: u32, out_point: [u8; 36]) -> Self { Self { - // TODO: change to const - asset_lock_type: 1, core_chain_locked_height, out_point: OutPoint::from(out_point), } } - /// Get proof type - pub fn asset_lock_type() -> u8 { - 1 - } - /// Create identifier pub fn create_identifier(&self) -> Result { let mut outpoint_bytes = Vec::new(); diff --git a/packages/rs-dpp/src/identity/state_transition/asset_lock_proof/instant/instant_asset_lock_proof.rs b/packages/rs-dpp/src/identity/state_transition/asset_lock_proof/instant/instant_asset_lock_proof.rs index 7b8d112b5c1..ba60113f4b1 100644 --- a/packages/rs-dpp/src/identity/state_transition/asset_lock_proof/instant/instant_asset_lock_proof.rs +++ b/packages/rs-dpp/src/identity/state_transition/asset_lock_proof/instant/instant_asset_lock_proof.rs @@ -22,8 +22,6 @@ use crate::ProtocolError; #[derive(Clone, Debug, Eq, PartialEq)] pub struct InstantAssetLockProof { - // TODO: Remove type - asset_lock_type: u8, instant_lock: InstantLock, transaction: Transaction, output_index: u32, @@ -63,7 +61,6 @@ impl Default for InstantAssetLockProof { fn default() -> Self { Self { // TODO: change to a const - asset_lock_type: 0, instant_lock: InstantLock::default(), transaction: Transaction { version: 0, @@ -80,25 +77,20 @@ impl Default for InstantAssetLockProof { impl InstantAssetLockProof { pub fn new(instant_lock: InstantLock, transaction: Transaction, output_index: u32) -> Self { Self { - // TODO: change the type to a const instant_lock, transaction, output_index, - asset_lock_type: 0, } } pub fn to_object(&self) -> Result { platform_value::to_value(self).map_err(ProtocolError::ValueError) } + pub fn to_cleaned_object(&self) -> Result { self.to_object() } - pub fn asset_lock_type(&self) -> u8 { - self.asset_lock_type - } - pub fn instant_lock(&self) -> &InstantLock { &self.instant_lock } @@ -156,7 +148,6 @@ impl InstantAssetLockProof { .consensus_encode(&mut transaction_buffer) .map_err(|e| ProtocolError::EncodingError(e.to_string()))?; - map.insert("type", self.asset_lock_type); map.insert("outputIndex", self.output_index); map.insert("transaction", transaction_buffer); map.insert("instantLock", is_lock_buffer); @@ -202,8 +193,6 @@ impl InstantAssetLockProof { #[serde(rename_all = "camelCase")] /// "Raw" instant lock for serialization pub struct RawInstantLockProof { - #[serde(rename = "type")] - lock_type: u8, instant_lock: BinaryData, transaction: BinaryData, output_index: u32, @@ -219,7 +208,6 @@ impl TryFrom for InstantAssetLockProof { .map_err(|e| ProtocolError::DecodingError(e.to_string()))?; Ok(Self { - asset_lock_type: raw_instant_lock.lock_type, transaction, instant_lock, output_index: raw_instant_lock.output_index, @@ -243,7 +231,6 @@ impl TryFrom<&InstantAssetLockProof> for RawInstantLockProof { .map_err(|e| ProtocolError::EncodingError(e.to_string()))?; Ok(Self { - lock_type: instant_asset_lock_proof.asset_lock_type, instant_lock: BinaryData::new(is_lock_buffer), transaction: BinaryData::new(transaction_buffer), output_index: instant_asset_lock_proof.output_index, diff --git a/packages/wasm-dpp/src/identity/state_transition/asset_lock_proof/chain/chain_asset_lock_proof.rs b/packages/wasm-dpp/src/identity/state_transition/asset_lock_proof/chain/chain_asset_lock_proof.rs index 91e4460ff62..8f2ca095eef 100644 --- a/packages/wasm-dpp/src/identity/state_transition/asset_lock_proof/chain/chain_asset_lock_proof.rs +++ b/packages/wasm-dpp/src/identity/state_transition/asset_lock_proof/chain/chain_asset_lock_proof.rs @@ -58,11 +58,6 @@ impl ChainAssetLockProofWasm { Ok(ChainAssetLockProofWasm(chain_asset_lock_proof)) } - #[wasm_bindgen(js_name=getType)] - pub fn get_type(&self) -> u8 { - ChainAssetLockProof::asset_lock_type() - } - #[wasm_bindgen(js_name=getCoreChainLockedHeight)] pub fn get_core_chain_locked_height(&self) -> u32 { self.0.core_chain_locked_height diff --git a/packages/wasm-dpp/src/identity/state_transition/asset_lock_proof/instant/instant_asset_lock_proof.rs b/packages/wasm-dpp/src/identity/state_transition/asset_lock_proof/instant/instant_asset_lock_proof.rs index 9d6872aad80..0a204296ef7 100644 --- a/packages/wasm-dpp/src/identity/state_transition/asset_lock_proof/instant/instant_asset_lock_proof.rs +++ b/packages/wasm-dpp/src/identity/state_transition/asset_lock_proof/instant/instant_asset_lock_proof.rs @@ -65,11 +65,6 @@ impl InstantAssetLockProofWasm { Ok(instant_asset_lock_proof.into()) } - #[wasm_bindgen(js_name=getType)] - pub fn get_type(&self) -> u8 { - self.0.asset_lock_type() - } - #[wasm_bindgen(js_name=getOutputIndex)] pub fn get_output_index(&self) -> usize { self.0.output_index() diff --git a/packages/wasm-dpp/test/unit/identity/stateTransition/assetLockProof/ChainAssetLockProof.spec.js b/packages/wasm-dpp/test/unit/identity/stateTransition/assetLockProof/ChainAssetLockProof.spec.js index c00a78608c2..4f26a8bea75 100644 --- a/packages/wasm-dpp/test/unit/identity/stateTransition/assetLockProof/ChainAssetLockProof.spec.js +++ b/packages/wasm-dpp/test/unit/identity/stateTransition/assetLockProof/ChainAssetLockProof.spec.js @@ -16,13 +16,6 @@ describe('ChainAssetLockProof', () => { ); }); - describe('#getType', () => { - it('should return correct type', () => { - expect(chainAssetLockProof.getType()) - .to.equal(chainAssetLockProofJS.getType()); - }); - }); - describe('#getCoreChainLockedHeight', () => { it('should return correct coreChainLockedHeight', () => { expect(chainAssetLockProof.getCoreChainLockedHeight())