Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure functions that should return Hex, do #193

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/hex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function isValidHexAddress(possibleAddress: Hex) {
* @returns The address encoded according to ERC-55.
* @see https://eips.ethereum.org/EIPS/eip-55
*/
export function getChecksumAddress(address: Hex) {
export function getChecksumAddress(address: Hex): Hex {
assert(is(address, HexChecksumAddressStruct), 'Invalid hex address.');
const unPrefixed = remove0x(address.toLowerCase());
const unPrefixedHash = remove0x(bytesToHex(keccak256(unPrefixed)));
Expand Down
5 changes: 3 additions & 2 deletions src/number.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { assert } from './assert';
import type { Hex } from './hex';
import { add0x, assertIsHexString } from './hex';

/**
Expand All @@ -18,7 +19,7 @@ import { add0x, assertIsHexString } from './hex';
* @returns The hexadecimal string, with the "0x"-prefix.
* @throws If the number is not a non-negative safe integer.
*/
export const numberToHex = (value: number): string => {
export const numberToHex = (value: number): Hex => {
assert(typeof value === 'number', 'Value must be a number.');
assert(value >= 0, 'Value must be a non-negative number.');
assert(
Expand All @@ -45,7 +46,7 @@ export const numberToHex = (value: number): string => {
* @returns The hexadecimal string, with the "0x"-prefix.
* @throws If the `bigint` is not a non-negative integer.
*/
export const bigIntToHex = (value: bigint): string => {
export const bigIntToHex = (value: bigint): Hex => {
assert(typeof value === 'bigint', 'Value must be a bigint.');
assert(value >= 0, 'Value must be a non-negative bigint.');

Expand Down
Loading