Skip to content

Commit

Permalink
Merge 8063ac7 into 44b2156
Browse files Browse the repository at this point in the history
  • Loading branch information
nflaig authored Aug 14, 2024
2 parents 44b2156 + 8063ac7 commit d5c779a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/utils/src/bytes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,15 @@ export function toHex(buffer: Uint8Array | Parameters<typeof Buffer.from>[0]): s
}

// Shared buffer to convert root to hex
const rootBuf = Buffer.alloc(32);
let rootBuf: Buffer | undefined;

/**
* Convert a Uint8Array, length 32, to 0x-prefixed hex string
*/
export function toRootHex(root: Uint8Array): string {
if (rootBuf === undefined) {
rootBuf = Buffer.alloc(32);
}
rootBuf.set(root);
return `0x${rootBuf.toString("hex")}`;
}
Expand Down

0 comments on commit d5c779a

Please sign in to comment.