Skip to content

Commit

Permalink
Fix tests where init admin is null
Browse files Browse the repository at this point in the history
  • Loading branch information
assafmo committed Jun 12, 2023
1 parent 9e619da commit 853e416
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ export const validateAddress = (
* @returns {Uint8Array} - The resulting bytes address.
*/
export function addressToBytes(address: string): Uint8Array {
if (address === "") {
return new Uint8Array(0);
}
return Uint8Array.from(bech32.fromWords(bech32.decode(address).words));
}

Expand All @@ -231,5 +234,8 @@ export function bytesToAddress(
bytes: Uint8Array,
prefix: string = "secret",
): string {
if (bytes.length === 0) {
return "";
}
return bech32.encode(prefix, bech32.toWords(bytes));
}

0 comments on commit 853e416

Please sign in to comment.