synapsecns/sanguine

View on GitHub
packages/sdk-router/src/utils/validateAndParseAddress.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { getAddress } from '@ethersproject/address'

/**
 * Validates an address and returns the parsed (checksummed) version of that address
 *
 * @param address the unchecksummed hex address
 */
export const validateAndParseAddress = (address: string): string => {
  try {
    return getAddress(address)
  } catch (error) {
    throw new Error(`${address} is not a valid address.`)
  }
}