import { isHexString , isValidAddress , isValidChecksumAddress , addHexPrefix , toChecksumAddress , zeroAddress } from "ethereumjs-util" ; export const BURN_ADDRESS = zeroAddress ( ) ; export function isBurnAddress ( address ) { return address === BURN_ADDRESS ; } param { string } possibleAddress param options param { boolean } options . allowNonPrefixed param { boolean } options . mixedCaseUseChecksum returns { boolean } export function isValidHexAddress ( possibleAddress , { allowNonPrefixed = true , mixedCaseUseChecksum = false } = { } ) { const addressToCheck = allowNonPrefixed ? addHexPrefix ( possibleAddress ) : possibleAddress ; if ( ! isHexString ( addressToCheck ) ) { return false ; } if ( mixedCaseUseChecksum ) { const prefixRemoved = addressToCheck . slice ( 2 ) ; const lower = prefixRemoved . toLowerCase ( ) ; const upper = prefixRemoved . toUpperCase ( ) ; const allOneCase = prefixRemoved === lower || prefixRemoved === upper ; if ( ! allOneCase ) { return isValidChecksumAddress ( addressToCheck ) ; } } return isValidAddress ( addressToCheck ) ; } export function toChecksumHexAddress ( address ) { if ( ! address ) { return "" ; } const hexPrefixed = addHexPrefix ( address ) ; if ( ! isHexString ( hexPrefixed ) ) { return hexPrefixed ; } return toChecksumAddress ( addHexPrefix ( address ) ) ; }