ens-tools
Version:
Opinionated ENS General Tooling
88 lines (73 loc) • 3.52 kB
TypeScript
import * as swr__internal from 'swr/_internal';
/**
* Convert EVM chainId to [SLIP-0044]() coinType as per [ENSIP-11](https://docs.ens.domains/ensip/11).
* @param chainId EVM chainId
* @returns SLIP-0044 coinType
*/
declare const convertEVMChainIdToCoinType: (chainId: number) => number;
/**
* Convert [SLIP-0044]() coinType to EVM chainId as per [ENSIP-11](https://docs.ens.domains/ensip/11).
* @param coinType SLIP-0044 coinType (above range 0x80000000 (2147483648))
* @returns EVM chainId
*/
declare const convertCoinTypeToEVMChainId: (coinType: number) => number;
declare const AddressRegex: RegExp;
/**
* Formats the address from 0x225f137127d9067788314bc7fcc1f36746a3c3B5 to 0x225f...c3B5
* Returns the address if it doesn't match the address pattern
* @param address The address to format
*/
declare const formatAddress: (address: string) => string;
declare type Types = 'com.twitter' | 'com.reddit' | 'com.github' | 'com.discord' | 'com.linkedin' | 'org.telegram' | 'website';
declare const formatRecord: (record: Types, value: string | undefined) => string | undefined;
declare type Rule = (value: string) => string | undefined;
declare const formatDiscordRules: Rule;
declare const formatLinkedinRules: Rule;
declare const formatRedditRules: Rule;
declare const formatTelegramRules: Rule;
declare const formatTwitterRules: Rule;
declare const formatWebsiteRules: Rule;
/**
* Supports ENSIP-9 & ENSIP-11
*/
declare type EnsMultichainAddressConfig = {
name: string;
coinType: number;
};
/**
* Gets the user's address for a given ENS name and coin type.
* CURRENTLY INCOMPLETE IMPLEMENTATION
* Based on: https://github.com/wagmi-dev/wagmi/blob/main/packages/react/src/hooks/ens/useEnsResolver.ts
*/
declare const useEnsMultichainAddress: ({ coinType, ...resolverConfig }: EnsMultichainAddressConfig) => any;
declare type EnsPreferredNameConfig = {
/** ENS name to look up */
name: string;
/** Fallback to use incase no `display` record */
fallback?: string;
};
declare type EnsPreferredNameResult = {
/**
* ENS name with capitalization following the `display` text record
* For more info see [ENSIP-5](https://docs.ens.domains/ens-improvement-proposals/ensip-5-text-records)
*/
data: string;
};
/**
* Gets the user's preferred ENS capitalization respecting the `display` text record.
* For more info see [ENSIP-5](https://docs.ens.domains/ens-improvement-proposals/ensip-5-text-records)
*/
declare const usePreferredName: ({ name, fallback, }: EnsPreferredNameConfig) => EnsPreferredNameResult;
declare type EnsRecordsConfig<K extends string> = {
/** ENS name (eg. "luc.eth") */
name: string;
/** Records (eg. ["com.github", "avatar", "com.discord"]) */
records: K[];
/** Wether to format/normalize the records */
format: boolean;
};
/**
* Gets the user's records for a given ENS.
*/
declare const useRecords: <K extends string>({ name, records, }: EnsRecordsConfig<K>) => swr__internal.SWRResponse<Record<K, string> | null, any, Partial<swr__internal.PublicConfiguration<Record<K, string> | null, any, swr__internal.BareFetcher<Record<K, string> | null>>> | undefined>;
export { AddressRegex, EnsMultichainAddressConfig, EnsRecordsConfig, convertCoinTypeToEVMChainId, convertEVMChainIdToCoinType, formatAddress, formatDiscordRules, formatLinkedinRules, formatRecord, formatRedditRules, formatTelegramRules, formatTwitterRules, formatWebsiteRules, useEnsMultichainAddress, usePreferredName, useRecords };