UNPKG

@unstoppabledomains/resolution

Version:
276 lines (275 loc) 6.94 kB
import { EventFilter, RequestArguments, RpcProviderLogEntry, TransactionRequest } from './index'; export declare type Api = { api: true; url?: string; network?: number; }; declare type NamingServiceSource = { url?: string; } | { provider?: Provider; }; export declare type UnsLayerSource = NamingServiceSource & { network: string; proxyServiceApiKey?: string; proxyReaderAddress?: string; blockchain?: BlockchainType; }; export declare type UnsInternalSource = { locations: { Layer1: UnsLayerSource; Layer2: UnsLayerSource; }; }; export declare type UnsSource = { locations: { Layer1?: UnsLayerSource; Layer2?: UnsLayerSource; eth?: UnsLayerSource; pol?: UnsLayerSource; base?: UnsLayerSource; }; }; export declare type EnsSource = NamingServiceSource & { network: string; registryAddress?: string; proxyServiceApiKey?: string; }; export declare type ZnsSource = NamingServiceSource & { network: string; registryAddress?: string; }; export declare type SourceConfig = { uns?: UnsSource | Api; zns?: ZnsSource | Api; ens?: EnsSource | Api; }; export declare type ResolutionConfig = { sourceConfig?: SourceConfig; apiKey?: string; }; export declare enum UnsLocation { Layer1 = "UNSLayer1", Layer2 = "UNSLayer2" } export declare enum NamingServiceName { UNS = "UNS", UNS_BASE = "UNS_BASE", ENS = "ENS", ZNS = "ZNS" } export declare type ResolutionMethod = NamingServiceName | UnsLocation | 'UDAPI'; export declare type AutoNetworkConfigs = { uns?: { locations: { Layer1: { url: string; } | { provider: Provider; }; Layer2: { url: string; } | { provider: Provider; }; }; }; ens?: { url: string; } | { provider: Provider; }; zns?: { url: string; } | { provider: Provider; }; }; /** * ResolutionResulution * @typedef ResolutionResponse * @property {Object} addresses - Resolution addresses for various currency addresses attached to the domain * @property {Object} meta - meta information about the owner of the domain */ export declare type ResolutionResponse = { addresses: { [key: string]: string; }; meta: { domain: string; owner: string | null; type: string; blockchain: BlockchainType | null; namehash: string; resolver: string; ttl: number; }; records: { [key: string]: string; }; }; export interface Web3Version0Provider { sendAsync: ProviderMethod; } export interface Web3Version1Provider { send: ProviderMethod; } export interface ZilliqaProvider { middleware: any; send<R = any, E = string>(method: string, ...params: any[]): Promise<any>; sendBatch<R = any, E = string>(method: string, ...params: any[]): Promise<any>; subscribe?(event: string, subscriber: any): symbol; unsubscribe?(token: symbol): void; } /** * @see https://eips.ethereum.org/EIPS/eip-1193 */ export interface Provider { request: (request: RequestArguments) => Promise<unknown>; } declare type ProviderMethod = (payload: JsonRpcPayload, callback: (error: Error | null, result?: JsonRpcResponse) => void) => void; export declare const UnclaimedDomainResponse: ResolutionResponse; /** * @see https://github.com/ethereum/web3.js/blob/1.x/packages/web3-core-helpers/types/index.d.ts#L216 */ export interface JsonRpcPayload { jsonrpc: string; method: string; params: any[]; id?: string | number; } export interface JsonRpcResponse { jsonrpc: string; id: number; result?: any; error?: string; } /** * @see https://github.com/ethers-io/ethers.js/blob/v5.0.4/packages/abstract-provider/src.ts/index.ts#L224 */ export interface EthersProvider { call(transaction: TransactionRequest, blockTag?: never): Promise<string>; getLogs(filter: EventFilter): Promise<RpcProviderLogEntry[]>; } export declare type NamehashOptions = { readonly format?: 'dec' | 'hex'; readonly prefix?: boolean; readonly zns?: boolean; }; export declare const NamehashOptionsDefault: { readonly format: "hex"; readonly prefix: true; readonly zns: false; }; export declare enum DnsRecordType { A = "A", AAAA = "AAAA", AFSDB = "AFSDB", APL = "APL", CAA = "CAA", CDNSKEY = "CDNSKEY", CDS = "CDS", CERT = "CERT", CNAME = "CNAME", CSYNC = "CSYNC", DHCID = "DHCID", DLV = "DLV", DNAME = "DNAME", DNSKEY = "DNSKEY", DS = "DS", EUI48 = "EUI48", EUI64 = "EUI64", HINFO = "HINFO", HIP = "HIP", HTTPS = "HTTPS", IPSECKEY = "IPSECKEY", KEY = "KEY", KX = "KX", LOC = "LOC", MX = "MX", NAPTR = "NAPTR", NS = "NS", NSEC = "NSEC", NSEC3 = "NSEC3", NSEC3PARAM = "NSEC3PARAM", OPENPGPKEY = "OPENPGPKEY", PTR = "PTR", RP = "RP", RRSIG = "RRSIG", SIG = "SIG", SMIMEA = "SMIMEA", SOA = "SOA", SRV = "SRV", SSHFP = "SSHFP", SVCB = "SVCB", TA = "TA", TKEY = "TKEY", TLSA = "TLSA", TSIG = "TSIG", TXT = "TXT", URI = "URI", ZONEMD = "ZONEMD" } export interface DnsRecord { type: DnsRecordType; TTL: number; data: string; } export declare type CryptoRecords = Record<string, string>; export declare type DomainData = { owner: string; resolver: string; records: CryptoRecords; location: UnsLocation; }; export interface Erc721Metadata { name: string; description: string; image: string; external_url: string; } export declare type TokenUriMetadataAttribute = { value: string | number; } | { trait_type: string; value: string | number; } | { display_type: 'number' | 'date' | 'boost_number' | 'boost_percentage' | 'ranking'; trait_type: string; value: number; }; export interface TokenUriMetadata extends Erc721Metadata { tokenId?: string; namehash?: string; external_link?: string; image_data?: string; image_url?: string; attributes?: Array<TokenUriMetadataAttribute>; background_color?: string; animation_url?: string; youtube_url?: string; } export interface DomainMetadata extends Erc721Metadata { properties: { records: CryptoRecords; }; } export declare enum BlockchainType { ETH = "ETH", POL = "POL", ZIL = "ZIL", BASE = "BASE" } export declare type DomainLocation = { registryAddress: string; resolverAddress: string; networkId: number; blockchain: BlockchainType; ownerAddress: string; blockchainProviderUrl: string; }; export declare type Locations = Record<string, DomainLocation | null>; export declare type ReverseResolutionOptions = { location?: UnsLocation; }; export {};