Skip to content

Commit

Permalink
chore: rename some fn
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek committed Nov 26, 2024
1 parent ff54061 commit 146d83d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
8 changes: 4 additions & 4 deletions packages/rs-dapi-client/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ where
}

/// Convert Result<T,TE> to ExecutionResult<R,E>, taking context from ExecutionResponse.
pub trait Wrap<R, RE, W>: Sized {
pub trait WrapToExecutionResult<R, RE, W>: Sized {
/// Convert self (eg. some [Result]) to [ExecutionResult], taking context information from `W` (eg. ExecutionResponse).
///
/// This function simplifies processing of results by wrapping them into ExecutionResult.
Expand Down Expand Up @@ -195,15 +195,15 @@ pub trait Wrap<R, RE, W>: Sized {
/// panic!("Expected error");
/// }
/// ```
fn wrap(self, result: &W) -> ExecutionResult<R, RE>;
fn wrap_to_execution_result(self, result: &W) -> ExecutionResult<R, RE>;
}

impl<R, RE, TR, IR, IRE> Wrap<R, RE, ExecutionResponse<TR>> for Result<IR, IRE>
impl<R, RE, TR, IR, IRE> WrapToExecutionResult<R, RE, ExecutionResponse<TR>> for Result<IR, IRE>
where
R: From<IR>,
RE: From<IRE>,
{
fn wrap(self, result: &ExecutionResponse<TR>) -> ExecutionResult<R, RE> {
fn wrap_to_execution_result(self, result: &ExecutionResponse<TR>) -> ExecutionResult<R, RE> {
match self {
Ok(r) => ExecutionResult::Ok(ExecutionResponse {
inner: r.into(),
Expand Down
2 changes: 1 addition & 1 deletion packages/rs-dapi-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub use dapi_client::{DapiClient, DapiClientError};
pub use dump::DumpData;
pub use executor::{
DapiRequestExecutor, ExecutionError, ExecutionResponse, ExecutionResult, InnerInto, IntoInner,
Wrap,
WrapToExecutionResult,
};
use futures::{future::BoxFuture, FutureExt};
pub use request_settings::RequestSettings;
Expand Down
20 changes: 14 additions & 6 deletions packages/rs-sdk/src/platform/transition/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use dpp::state_transition::StateTransition;
use drive::drive::Drive;
use drive_proof_verifier::error::ContextProviderError;
use drive_proof_verifier::DataContractProvider;
use rs_dapi_client::Wrap;
use rs_dapi_client::WrapToExecutionResult;
use rs_dapi_client::{DapiRequest, ExecutionError, InnerInto, IntoInner, RequestSettings};

#[async_trait::async_trait]
Expand Down Expand Up @@ -80,9 +80,17 @@ impl BroadcastStateTransition for StateTransition {
let response = request.execute(sdk, request_settings).await.inner_into()?;

let grpc_response: &WaitForStateTransitionResultResponse = &response.inner;
let metadata = grpc_response.metadata().wrap(&response)?.inner;
let block_info = block_info_from_metadata(metadata).wrap(&response)?.inner;
let proof: &Proof = (*grpc_response).proof().wrap(&response)?.inner;
let metadata = grpc_response
.metadata()
.wrap_to_execution_result(&response)?
.inner;
let block_info = block_info_from_metadata(metadata)
.wrap_to_execution_result(&response)?
.inner;
let proof: &Proof = (*grpc_response)
.proof()
.wrap_to_execution_result(&response)?
.inner;

let context_provider = sdk.context_provider().ok_or(ExecutionError {
inner: Error::from(ContextProviderError::Config(
Expand All @@ -99,7 +107,7 @@ impl BroadcastStateTransition for StateTransition {
&context_provider.as_contract_lookup_fn(),
sdk.version(),
)
.wrap(&response)?
.wrap_to_execution_result(&response)?
.inner;

let variant_name = result.to_string();
Expand All @@ -111,7 +119,7 @@ impl BroadcastStateTransition for StateTransition {
std::any::type_name::<T>(),
))
})
.wrap(&response)
.wrap_to_execution_result(&response)
};

let future = retry(retry_settings, factory);
Expand Down

0 comments on commit 146d83d

Please sign in to comment.