From cc4d422be6a0c54d2bed2aa14379815228f42ed3 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Mon, 25 Sep 2023 12:41:54 +0400 Subject: [PATCH] feat: added bytesToBech32Bytes helper function --- contracts/BytesHelperLib.sol | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/contracts/BytesHelperLib.sol b/contracts/BytesHelperLib.sol index e045af63..22f4a06d 100644 --- a/contracts/BytesHelperLib.sol +++ b/contracts/BytesHelperLib.sol @@ -27,4 +27,16 @@ library BytesHelperLib { ) internal pure returns (bytes32) { return bytes32(uint256(uint160(someAddress))); } + + function bytesToBech32Bytes( + bytes calldata data, + uint256 offset + ) internal pure returns (bytes memory) { + bytes memory bech32Bytes = new bytes(42); + for (uint i = 0; i < 42; i++) { + bech32Bytes[i] = data[i + offset]; + } + + return bech32Bytes; + } }