Skip to content

Commit

Permalink
fix: remove extra 0x in outputted text when pop up (#298)
Browse files Browse the repository at this point in the history
* fix: bug: extra 0x in outputted text

* fix: test

* fix: add 0x when error
  • Loading branch information
AlexD10S committed Sep 2, 2024
1 parent 43b592b commit 1d41cd4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/pop-contracts/src/up.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ pub async fn upload_smart_contract(
.await
.map_err(|error_variant| Error::UploadContractError(format!("{:?}", error_variant)))?;
if let Some(code_stored) = upload_result.code_stored {
return Ok(format!("0x{:?}", code_stored.code_hash));
return Ok(format!("{:?}", code_stored.code_hash));
} else {
let code_hash: String =
upload_exec.code().code_hash().iter().map(|b| format!("{:02x}", b)).collect();
Expand Down Expand Up @@ -330,6 +330,7 @@ mod tests {
};
let upload_exec = set_up_upload(up_opts).await?;
let upload_result = dry_run_upload(&upload_exec).await?;
assert!(!upload_result.code_hash.starts_with("0x0x"));
assert!(upload_result.code_hash.starts_with("0x"));
Ok(())
}
Expand Down Expand Up @@ -361,6 +362,7 @@ mod tests {

// Only upload a Smart Contract
let upload_result = upload_smart_contract(&upload_exec).await?;
assert!(!upload_result.starts_with("0x0x"));
assert!(upload_result.starts_with("0x"));
//Error when Smart Contract has been already uploaded
assert!(matches!(
Expand Down

0 comments on commit 1d41cd4

Please sign in to comment.