Skip to content

Commit

Permalink
Some BlockWrapper ID/params/dto nits (#1329)
Browse files Browse the repository at this point in the history
  • Loading branch information
thibault-martinez authored Sep 26, 2023
1 parent 5433831 commit f0b92eb
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
13 changes: 5 additions & 8 deletions bindings/core/src/method_handler/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,11 @@ pub(crate) async fn call_client_method_internal(client: &Client, method: ClientM
.await?;
Response::CustomJson(data)
}
ClientMethod::BlockId { block } => Response::BlockId(
client
.block_id(&BlockWrapper::try_from_dto_with_params(
block,
client.get_protocol_parameters().await?,
)?)
.await?,
),
ClientMethod::BlockId { block } => {
let protocol_parameters = client.get_protocol_parameters().await?;
let block = BlockWrapper::try_from_dto_with_params(block, &protocol_parameters)?;
Response::BlockId(block.id(&protocol_parameters))
}
};
Ok(response)
}
2 changes: 1 addition & 1 deletion bindings/core/src/method_handler/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub(crate) fn call_utils_method_internal(method: UtilsMethod) -> Result<Response
block,
protocol_parameters,
} => {
let block = BlockWrapper::try_from_dto_with_params(block, protocol_parameters.clone())?;
let block = BlockWrapper::try_from_dto_with_params(block, &protocol_parameters)?;
Response::BlockId(block.id(&protocol_parameters))
}
UtilsMethod::TransactionId { payload } => {
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/types/block/output/foundry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ mod tests {
let dto = OutputDto::Foundry((&output).into());
let output_unver = Output::try_from_dto(dto.clone()).unwrap();
assert_eq!(&output, output_unver.as_foundry());
let output_ver = Output::try_from_dto_with_params(dto, protocol_parameters.clone()).unwrap();
let output_ver = Output::try_from_dto_with_params(dto, &protocol_parameters).unwrap();
assert_eq!(&output, output_ver.as_foundry());

let foundry_id = FoundryId::build(&rand_account_address(), 0, SimpleTokenScheme::KIND);
Expand Down
4 changes: 2 additions & 2 deletions sdk/tests/types/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ fn dto_mismatch_version() {
}
});
let block_dto = serde_json::from_value::<BlockWrapperDto>(block_dto_json).unwrap();
let block_res = BlockWrapper::try_from_dto_with_params(block_dto, protocol_parameters.clone());
let block_res = BlockWrapper::try_from_dto_with_params(block_dto, &protocol_parameters);

assert_eq!(
block_res,
Expand Down Expand Up @@ -193,7 +193,7 @@ fn dto_mismatch_network_id() {
}
});
let block_dto = serde_json::from_value::<BlockWrapperDto>(block_dto_json).unwrap();
let block_res = BlockWrapper::try_from_dto_with_params(block_dto, protocol_parameters.clone());
let block_res = BlockWrapper::try_from_dto_with_params(block_dto, &protocol_parameters);

assert_eq!(
block_res,
Expand Down

0 comments on commit f0b92eb

Please sign in to comment.