From a7a4c15b17f56977815060f9499965e6ed0b21b4 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Thu, 22 Aug 2024 16:11:12 +0200 Subject: [PATCH] fix(sdk): use proofs when waiting for asset lock --- .../src/from_request.rs | 2 +- packages/rs-sdk/src/core/transaction.rs | 31 +++---------------- packages/rs-sdk/src/platform/types/epoch.rs | 3 ++ .../rs-sdk/src/platform/types/identity.rs | 2 +- 4 files changed, 9 insertions(+), 29 deletions(-) diff --git a/packages/rs-drive-proof-verifier/src/from_request.rs b/packages/rs-drive-proof-verifier/src/from_request.rs index ff2a74de36c..d8a302cb9a9 100644 --- a/packages/rs-drive-proof-verifier/src/from_request.rs +++ b/packages/rs-drive-proof-verifier/src/from_request.rs @@ -200,7 +200,7 @@ impl TryFromRequest } Ok(proto::get_contested_resource_identity_votes_request::GetContestedResourceIdentityVotesRequestV0 { - prove: true, + prove: true, identity_id: self.identity_id.to_vec(), offset: self.offset.map(|x| x as u32), limit: self.limit.map(|x| x as u32), diff --git a/packages/rs-sdk/src/core/transaction.rs b/packages/rs-sdk/src/core/transaction.rs index a7046a2fdb6..39dd85e562c 100644 --- a/packages/rs-sdk/src/core/transaction.rs +++ b/packages/rs-sdk/src/core/transaction.rs @@ -1,12 +1,11 @@ +use crate::platform::fetch_current_no_parameters::FetchCurrent; +use crate::platform::types::epoch::Epoch; use crate::{Error, Sdk}; use bip37_bloom_filter::{BloomFilter, BloomFilterData}; use dapi_grpc::core::v0::{ transactions_with_proofs_request, transactions_with_proofs_response, GetTransactionRequest, GetTransactionResponse, TransactionsWithProofsRequest, TransactionsWithProofsResponse, }; -use dapi_grpc::platform::v0::{ - get_epochs_info_request, get_epochs_info_response, GetEpochsInfoRequest, GetEpochsInfoResponse, -}; use dpp::dashcore::consensus::Decodable; use dpp::dashcore::{Address, InstantLock, MerkleBlock, OutPoint, Transaction, Txid}; use dpp::identity::state_transition::asset_lock_proof::chain::ChainAssetLockProof; @@ -201,30 +200,8 @@ impl Sdk { // Wait until platform chain is on the block's chain locked height loop { - let request = GetEpochsInfoRequest { - version: Some(get_epochs_info_request::Version::V0( - get_epochs_info_request::GetEpochsInfoRequestV0 { - start_epoch: Some(0), - count: 1, - ..Default::default() - }, - )), - }; - - let GetEpochsInfoResponse { - version: - Some(get_epochs_info_response::Version::V0( - get_epochs_info_response::GetEpochsInfoResponseV0 { - metadata: Some(metadata), - .. - }, - )), - } = self.execute(request, RequestSettings::default()).await? - else { - return Err(Error::DapiClientError(String::from( - "missing V0 `metadata` field", - ))); - }; + let (_epoch, metadata) = + Epoch::fetch_current_with_metadata(self).await?; if metadata.core_chain_locked_height >= core_chain_locked_height { break; diff --git a/packages/rs-sdk/src/platform/types/epoch.rs b/packages/rs-sdk/src/platform/types/epoch.rs index 7026f2e5516..f6b86b77eeb 100644 --- a/packages/rs-sdk/src/platform/types/epoch.rs +++ b/packages/rs-sdk/src/platform/types/epoch.rs @@ -9,6 +9,9 @@ use crate::{ Error, Sdk, }; +/// Epoch type used in the SDK. +pub type Epoch = ExtendedEpochInfo; + #[async_trait] impl FetchCurrent for ExtendedEpochInfo { async fn fetch_current(sdk: &Sdk) -> Result { diff --git a/packages/rs-sdk/src/platform/types/identity.rs b/packages/rs-sdk/src/platform/types/identity.rs index 01599307c1a..bc375a67d7c 100644 --- a/packages/rs-sdk/src/platform/types/identity.rs +++ b/packages/rs-sdk/src/platform/types/identity.rs @@ -39,7 +39,7 @@ impl Query for dpp::prelude::Identifier { Ok(IdentityRequest::GetIdentity(GetIdentityRequest { version: Some(get_identity_request::Version::V0(GetIdentityRequestV0 { id, - prove: true, + prove, })), })) }