Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
frangio committed Nov 2, 2024
1 parent c25898f commit 151be1d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/bytes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ function toBytes(value: BytesLike): Bytes {
}
}

function toHex(value: BytesLike): string {
function toHex(value: BytesLike): HexString {
if (typeof value === 'string') {
hexToBytes(value); // assert hex string
return value;
return value.replace(/^(0x)?/, '0x');
} else if (value instanceof Uint8Array) {
return '0x' + bytesToHex(value);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export function isValidMerkleTree(tree: BytesLike[], nodeHash: NodeHash = standa
return tree.length > 0;
}

export function renderMerkleTree(tree: BytesLike[]): string {
export function renderMerkleTree(tree: BytesLike[]): HexString {
validateArgument(tree.length !== 0, 'Expected non-zero number of nodes');

const stack: [number, number[]][] = [[0, []]];
Expand Down
2 changes: 1 addition & 1 deletion src/hashes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { encode } from '@metamask/abi-utils';
import { keccak256 as _keccak256 } from 'ethereum-cryptography/keccak.js';
import { keccak256 as _keccak256 } from 'ethereum-cryptography/keccak';
import { BytesLike, HexString, toHex, toBytes, concat, compare } from './bytes';

export type LeafHash<T> = (leaf: T) => HexString;
Expand Down

0 comments on commit 151be1d

Please sign in to comment.