UNPKG

web3-domain-resolver

Version:

Web3 Library that enable with just one function to resolve domains on multiple web3 providers such as ENS, UnstoppableDomains and Freename

43 lines (42 loc) 2.49 kB
import { IResolverProvider } from "../resolver-providers/resolver-provider.interface"; import { IResolvedResource } from "./resolved-resource/resolved-resource.interface"; import { ProviderName } from "./types/resolver-name"; export declare class Resolver { constructor(resolverProviders: IResolverProvider[]); private _resolverProviderRouter; /** * Set the order in which the resolver providers are interrogated to resolve a name or tokenId. * @param priority the new priority of the providers. */ setResolversPriority(priority: Array<ProviderName | string>): void; /** * Adds resolver providers to the Resolver. * @param resolverProviders the resolver providers to add. */ addResolverProviders(resolverProviders: IResolverProvider | IResolverProvider[]): void; /** * Resolve the given domain fullname or tld. * If the domain is valid, exists on the blockchain and can be resolved a `IResolvedResource` is given, otherwise the result is `undefined`. * To obtain the resolved resource a series of calls to the blockchain are made, depending on the chain traffic the `resolve` call can take a couple of seconds to be completed. * @param domainOrTld the domain to resolve. Eg. `"test.web3domain"` * @returns an `IResolvedResource` instance or `undefined`. */ resolve(domainOrTld: string): Promise<IResolvedResource | undefined>; /** * Resolves the given tokenId. * If the tokenId is valid, exists on the blockchain and can be resolved a `IResolvedResource` is given, otherwise the result is `undefined`. * To obtain the resolved resource a series of calls to the blockchain are made, depending on the chain traffic the `resolveFromTokenId` call can take a couple of seconds to be completed. * To speed up the resolution a `ResolverName` can be provided, in this case only the given provider is checked. * @param tokenId the NFT tokenId uint256 string rappresentation to resolve * @param resolverProviderName the provider of the tokenId to resolve * @returns an `IResolvedResource` instance or `undefined`. */ resolveFromTokenId(tokenId: string, resolverProviderName?: ProviderName | string): Promise<IResolvedResource | undefined>; /** * * @param address * @param resolverProviderName * @returns */ reverseResolve(address: string, resolverProviderName?: ProviderName | string): Promise<IResolvedResource | undefined>; }