Skip to content

Commit

Permalink
fix(sdk): use proofs when waiting for asset lock (#2067)
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek authored Sep 4, 2024
1 parent 76cfbd9 commit 7f350a6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 29 deletions.
2 changes: 1 addition & 1 deletion packages/rs-drive-proof-verifier/src/from_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ impl TryFromRequest<GetContestedResourceIdentityVotesRequest>
}

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),
Expand Down
31 changes: 4 additions & 27 deletions packages/rs-sdk/src/core/transaction.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions packages/rs-sdk/src/platform/types/epoch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self, Error> {
Expand Down
2 changes: 1 addition & 1 deletion packages/rs-sdk/src/platform/types/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl Query<IdentityRequest> for dpp::prelude::Identifier {
Ok(IdentityRequest::GetIdentity(GetIdentityRequest {
version: Some(get_identity_request::Version::V0(GetIdentityRequestV0 {
id,
prove: true,
prove,
})),
}))
}
Expand Down

0 comments on commit 7f350a6

Please sign in to comment.