UNPKG

@hyperlane-xyz/utils

Version:

General utilities and types for the Hyperlane network

90 lines 6.97 kB
import { Address, HexString, ProtocolType } from './types.js'; export declare const ZERO_ADDRESS_HEX_32 = "0x0000000000000000000000000000000000000000000000000000000000000000"; export declare function isAddressEvm(address: Address): boolean; export declare function isAddressSealevel(address: Address): boolean; export declare function isAddressCosmos(address: Address): boolean; export declare function isAddressCosmosNative(address: Address): boolean; export declare function isCosmosIbcDenomAddress(address: Address): boolean; export declare function isAddressStarknet(address: Address): boolean; export declare function isAddressRadix(address: Address): boolean; export declare function isAddressAleo(address: Address): boolean; export declare function isAddressTron(address: Address): boolean; export declare function getAddressProtocolType(address: Address): ProtocolType.Ethereum | ProtocolType.Sealevel | ProtocolType.Cosmos | ProtocolType.CosmosNative | ProtocolType.Starknet | ProtocolType.Radix | ProtocolType.Aleo | ProtocolType.Tron | undefined; export declare function isAddress(address: Address): boolean; export declare function isValidAddressEvm(address: Address): boolean; export declare function isValidAddressSealevel(address: Address): boolean; export declare function isValidAddressCosmos(address: Address): boolean; export declare function isValidAddressStarknet(address: Address): boolean; export declare function isValidAddressRadix(address: Address): boolean; export declare function isValidAddressAleo(address: Address): boolean; export declare function isValidAddressTron(address: Address): boolean; export declare function isValidAddress(address: Address, protocol?: ProtocolType): boolean; export declare function normalizeAddressEvm(address: Address): string; export declare function normalizeAddressSealevel(address: Address): string; export declare function normalizeAddressCosmos(address: Address): string; export declare function normalizeAddressStarknet(address: Address): string; export declare function normalizeAddressRadix(address: Address): string; export declare function normalizeAddressAleo(address: Address): string; export declare function normalizeAddressTron(address: Address): string; export declare function normalizeAddress(address: Address, protocol?: ProtocolType): string; export declare function eqAddressEvm(a1: Address, a2: Address): boolean; export declare function eqAddressSol(a1: Address, a2: Address): boolean; export declare function eqAddressCosmos(a1: Address, a2: Address): boolean; export declare function eqAddressStarknet(a1: Address, a2: Address): boolean; export declare function eqAddressRadix(a1: Address, a2: Address): boolean; export declare function eqAddressAleo(a1: Address, a2: Address): boolean; export declare function eqAddressTron(a1: Address, a2: Address): boolean; export declare function eqAddress(a1: Address, a2: Address): boolean; export declare function isValidTransactionHashEvm(input: string): boolean; export declare function isValidTransactionHashSealevel(input: string): boolean; export declare function isValidTransactionHashCosmos(input: string): boolean; export declare function isValidTransactionHashStarknet(input: string): boolean; export declare function isValidTransactionHashRadix(input: string): boolean; export declare function isValidTransactionHashAleo(input: string): boolean; export declare function isValidTransactionHashTron(input: string): boolean; export declare function isValidTransactionHash(input: string, protocol: ProtocolType): boolean; export declare function isZeroishAddress(address: Address): boolean; /** * Compares two optional addresses, treating undefined and zeroish addresses as equivalent. * Useful for comparing optional contract addresses (ISM, hooks, etc.) where both * undefined and zero address mean "not set" or "use default". * * @param a1 First address (can be undefined) * @param a2 Second address (can be undefined) * @param eqFn Protocol-specific address equality function (e.g., eqAddressEvm, eqAddressRadix) * @returns true if addresses are equivalent (both unset/zeroish or both set to same address) */ export declare function eqOptionalAddress(a1: Address | undefined, a2: Address | undefined, eqFn: (a1: Address, a2: Address) => boolean): boolean; export declare function shortenAddress(address: Address, capitalize?: boolean): string; export declare function capitalizeAddress(address: Address): string; export declare function addressToBytes32Evm(address: Address): string; export declare function bytes32ToAddress(bytes32: HexString): Address; export declare function addressToBytesEvm(address: Address): Uint8Array; export declare function addressToBytesSol(address: Address): Uint8Array; export declare function addressToBytesCosmos(address: Address): Uint8Array; export declare function addressToBytesCosmosNative(address: Address): Uint8Array; export declare function addressToBytesStarknet(address: Address): Uint8Array; export declare function addressToBytesRadix(address: Address): Uint8Array; export declare function addressToBytesAleo(address: Address): Uint8Array; export declare function addressToBytesTron(address: Address): Uint8Array; export declare function addressToBytes(address: Address, protocol?: ProtocolType): Uint8Array; export declare function addressToByteHexString(address: string, protocol?: ProtocolType): string; export declare function addressToBytes32(address: Address, protocol?: ProtocolType): string; export declare function bytesToBytes32(bytes: Uint8Array): string; export declare function padBytesToLength(bytes: Uint8Array, length: number): Buffer<ArrayBuffer>; export declare function bytesToAddressEvm(bytes: Uint8Array): Address; export declare function bytesToAddressSol(bytes: Uint8Array): Address; export declare function bytesToAddressCosmos(bytes: Uint8Array, prefix: string): Address; export declare function bytesToAddressCosmosNative(bytes: Uint8Array, prefix: string): Address; export declare function bytesToAddressStarknet(bytes: Uint8Array): Address; export declare function bytesToAddressRadix(bytes: Uint8Array, prefix: string): Address; export declare function bytesToAddressAleo(bytes: Uint8Array): Address; export declare function bytesToAddressTron(bytes: Uint8Array): Address; export declare function bytesToProtocolAddress(bytes: Uint8Array, toProtocol: ProtocolType, prefix?: string): string; export declare function convertToProtocolAddress(address: string, protocol: ProtocolType, prefix?: string): string; export declare function ensure0x(hexstr: string): string; export declare function strip0x(hexstr: string): string; export declare function isPrivateKeyEvm(privateKey: string): boolean; export declare function hexToBech32mPrefix(hex: string, prefix: string, length?: number): string; export declare function hexToRadixCustomPrefix(hex: string, module: string, prefix?: string, length?: number): string; //# sourceMappingURL=addresses.d.ts.map