Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some BlockWrapper ID/params/dto nits #1329

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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