Skip to content

Commit

Permalink
fix: Update eth module return types to use PrefixedHexString
Browse files Browse the repository at this point in the history
  • Loading branch information
schaable committed Oct 11, 2024
1 parent be12b01 commit 9a11fe8
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions v-next/hardhat-utils/src/eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
* @param value The value to check.
* @returns True if the value is an Ethereum address, false otherwise.
*/
export function isAddress(value: unknown): boolean {
export function isAddress(value: unknown): value is PrefixedHexString {
return typeof value === "string" && /^0x[0-9a-f]{40}$/i.test(value);
}

Expand All @@ -24,9 +24,7 @@ export function isAddress(value: unknown): boolean {
* @returns True if the value is an Ethereum address with a valid checksum, false otherwise.
*/
export async function isValidChecksumAddress(value: unknown): Promise<boolean> {
return (
typeof value === "string" && isAddress(value) && isValidChecksum(value)
);
return isAddress(value) && isValidChecksum(value);
}

/**
Expand All @@ -35,7 +33,7 @@ export async function isValidChecksumAddress(value: unknown): Promise<boolean> {
* @param value The value to check.
* @returns True if the value is an Ethereum hash, false otherwise.
*/
export function isHash(value: unknown): boolean {
export function isHash(value: unknown): value is PrefixedHexString {
return typeof value === "string" && /^0x[0-9a-f]{64}$/i.test(value);
}

Expand All @@ -46,7 +44,7 @@ export function isHash(value: unknown): boolean {
* @returns The hexadecimal representation of the number padded to 32 bytes.
* @throws InvalidParameterError If the input is not a safe integer or is negative.
*/
export function toEvmWord(value: bigint | number): string {
export function toEvmWord(value: bigint | number): PrefixedHexString {
return setLengthLeft(numberToHexString(value), 64);
}

Expand Down

0 comments on commit 9a11fe8

Please sign in to comment.