From 809d768ab9658ff1be45b95f9153c2675af2a760 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Tue, 26 Sep 2023 14:56:50 +0200 Subject: [PATCH] Some BlockWrapper ID/params/dto nits --- bindings/core/src/method_handler/client.rs | 13 +++++-------- bindings/core/src/method_handler/utils.rs | 2 +- sdk/src/types/block/output/foundry.rs | 2 +- sdk/tests/types/block.rs | 4 ++-- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/bindings/core/src/method_handler/client.rs b/bindings/core/src/method_handler/client.rs index 40347336dc..bfae35f84b 100644 --- a/bindings/core/src/method_handler/client.rs +++ b/bindings/core/src/method_handler/client.rs @@ -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) } diff --git a/bindings/core/src/method_handler/utils.rs b/bindings/core/src/method_handler/utils.rs index 2ab9d4de68..9b35265845 100644 --- a/bindings/core/src/method_handler/utils.rs +++ b/bindings/core/src/method_handler/utils.rs @@ -41,7 +41,7 @@ pub(crate) fn call_utils_method_internal(method: UtilsMethod) -> Result { - 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 } => { diff --git a/sdk/src/types/block/output/foundry.rs b/sdk/src/types/block/output/foundry.rs index ae07e1ac26..fc09a18e41 100644 --- a/sdk/src/types/block/output/foundry.rs +++ b/sdk/src/types/block/output/foundry.rs @@ -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); diff --git a/sdk/tests/types/block.rs b/sdk/tests/types/block.rs index a9c9a187b2..a2939defba 100644 --- a/sdk/tests/types/block.rs +++ b/sdk/tests/types/block.rs @@ -152,7 +152,7 @@ fn dto_mismatch_version() { } }); let block_dto = serde_json::from_value::(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, @@ -193,7 +193,7 @@ fn dto_mismatch_network_id() { } }); let block_dto = serde_json::from_value::(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,