Skip to content

Commit

Permalink
Fix Indy-Besu formatting
Browse files Browse the repository at this point in the history
Signed-off-by: aziz.karabashov <[email protected]>
  • Loading branch information
akarabashov committed Dec 11, 2023
1 parent 031cf6f commit d0fd1f4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
7 changes: 4 additions & 3 deletions indy-besu/smart_contracts/contracts/utils/StringUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ library StringUtils {
bytes1 private constant _ASCII_SMALL_A = 0x61;
bytes1 private constant _ASCII_SMALL_F = 0x66;
string private constant _HEX_PREFIX = "0x";
bytes private constant _ZERO_BYTES = "";

/**
* @dev Checks if two strings are equal.
Expand Down Expand Up @@ -61,17 +62,17 @@ library StringUtils {
StrSlice hexPrefixSlice = _HEX_PREFIX.toSlice();

// Check and remove hex prefix
if (!hexStringSlice.startsWith(_HEX_PREFIX.toSlice())) return "";
if (!hexStringSlice.startsWith(_HEX_PREFIX.toSlice())) return _ZERO_BYTES;
hexString = hexStringSlice.stripPrefix(hexPrefixSlice).toString();

bytes memory hexStringBytes = bytes(hexString);
bytes memory resultBytes = new bytes(hexStringBytes.length / 2);
for (uint256 i = 0; i < resultBytes.length; i++) {
(uint8 firstByte, bool firstByteValid) = _hexCharToByte(hexStringBytes[2 * i]);
if (!firstByteValid) return "";
if (!firstByteValid) return _ZERO_BYTES;

(uint8 secondByte, bool secondByteValid) = _hexCharToByte(hexStringBytes[2 * i + 1]);
if (!secondByteValid) return "";
if (!secondByteValid) return _ZERO_BYTES;

resultBytes[i] = bytes1(firstByte * 16 + secondByte);
}
Expand Down
3 changes: 2 additions & 1 deletion indy-besu/vdr/src/contracts/did/did_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,8 @@ pub mod test {
init_env_logger();
let client = client(None);
let transaction =
IndyDidRegistry::build_resolve_did_transaction(&client, &DID::new(ISSUER_ID)).unwrap();
IndyDidRegistry::build_resolve_did_transaction(&client, &DID::new(ISSUER_ID))
.unwrap();
let expected_transaction = Transaction {
type_: TransactionType::Read,
from: None,
Expand Down
13 changes: 8 additions & 5 deletions indy-besu/vdr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ mod tests {
// write
let did_doc = did_doc(None);
let transaction =
IndyDidRegistry::build_create_did_transaction(&client, &TRUSTEE_ACC, &did_doc).unwrap();
IndyDidRegistry::build_create_did_transaction(&client, &TRUSTEE_ACC, &did_doc)
.unwrap();
let signed_transaction = client.sign_transaction(&transaction).await.unwrap();
let block_hash = client
.submit_transaction(&signed_transaction)
Expand All @@ -85,7 +86,8 @@ mod tests {
let transaction =
IndyDidRegistry::build_resolve_did_transaction(&client, &did_doc.id).unwrap();
let result = client.submit_transaction(&transaction).await.unwrap();
let resolved_did_doc = IndyDidRegistry::parse_resolve_did_result(&client, &result).unwrap();
let resolved_did_doc =
IndyDidRegistry::parse_resolve_did_result(&client, &result).unwrap();
assert_eq!(did_doc, resolved_did_doc);

Ok(())
Expand Down Expand Up @@ -120,9 +122,10 @@ mod tests {
.await
.unwrap();

let receipt = IndyDidRegistry::deactivate_did(&second_client, &TRUSTEE2_ACC, &did_doc.id)
.await
.unwrap();
let receipt =
IndyDidRegistry::deactivate_did(&second_client, &TRUSTEE2_ACC, &did_doc.id)
.await
.unwrap();
println!("Receipt: {}", receipt);

Ok(())
Expand Down

0 comments on commit d0fd1f4

Please sign in to comment.