ox
Version:
Ethereum Standard Library
88 lines • 3.48 kB
TypeScript
import * as Bytes from './Bytes.js';
import * as Errors from './Errors.js';
import * as Hash from './Hash.js';
import * as Hex from './Hex.js';
import * as internal from './internal/ens.js';
/**
* Hashes ENS label.
*
* Since ENS labels prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to [normalize ENS labels](https://docs.ens.domains/contract-api-reference/name-processing#normalising-names) with [UTS-46 normalization](https://unicode.org/reports/tr46) before passing them to `labelhash`. You can use the built-in {@link ox#Ens.(normalize:function)} function for this.
*
* @example
* ```ts twoslash
* import { Ens } from 'ox'
* Ens.labelhash('eth')
* ;('0x4f5b812789fc606be1b3b16908db13fc7a9adf7ca72641f84d75b47069d3d7f0')
* ```
*
* @param label - ENS label.
* @returns ENS labelhash.
*/
export declare function labelhash(label: string): `0x${string}`;
export declare namespace labelhash {
type ErrorType = Hex.fromBytes.ErrorType | internal.unwrapLabelhash.ErrorType | Hash.keccak256.ErrorType | Hex.fromString.ErrorType | Errors.GlobalErrorType;
}
/**
* Hashes ENS name.
*
* Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to [normalize ENS names](https://docs.ens.domains/contract-api-reference/name-processing#normalising-names) with [UTS-46 normalization](https://unicode.org/reports/tr46) before passing them to `namehash`. You can use the built-in {@link ox#Ens.(normalize:function)} function for this.
*
* @example
* ```ts twoslash
* import { Ens } from 'ox'
* Ens.namehash('wevm.eth')
* // @log: '0xf246651c1b9a6b141d19c2604e9a58f567973833990f830d882534a747801359'
* ```
*
* @param name - ENS name.
* @returns ENS namehash.
*/
export declare function namehash(name: string): `0x${string}`;
export declare namespace namehash {
type ErrorType = Hex.fromBytes.ErrorType | internal.unwrapLabelhash.ErrorType | Bytes.fromHex.ErrorType | Hash.keccak256.ErrorType | Bytes.fromString.ErrorType | Bytes.concat.ErrorType | Errors.GlobalErrorType;
}
/**
* Normalizes ENS name according to [ENSIP-15](https://github.com/ensdomains/docs/blob/9edf9443de4333a0ea7ec658a870672d5d180d53/ens-improvement-proposals/ensip-15-normalization-standard.md).
*
* For more info see [ENS documentation](https://docs.ens.domains/contract-api-reference/name-processing#normalising-names) on name processing.
*
* @example
* ```ts twoslash
* import { Ens } from 'ox'
* Ens.normalize('wevm.eth')
* // @log: 'wevm.eth'
* ```
*
* @param name - ENS name.
* @returns Normalized ENS name.
*/
export declare function normalize(name: string): string;
export declare namespace normalize {
type ErrorType = Errors.GlobalErrorType;
}
/**
* Converts a chain ID to an ENSIP-9 compliant coin type.
*
* @example
* ```ts twoslash
* import { Ens } from 'ox'
*
* Ens.toCoinType(10n)
* // @log: 2147483658n
* ```
*
* @param chainId - Chain ID to convert.
* @returns ENS coin type.
*/
export declare function toCoinType(chainId: bigint): bigint;
export declare namespace toCoinType {
type ErrorType = typeof InvalidChainIdError | Errors.GlobalErrorType;
}
/** Thrown when an ENS chain ID is invalid. */
export declare class InvalidChainIdError extends Errors.BaseError {
readonly name = "Ens.InvalidChainIdError";
constructor({ chainId }: {
chainId: bigint;
});
}
//# sourceMappingURL=Ens.d.ts.map