UNPKG

3.67 kBTypeScriptView Raw
1import { Blockchain, ResolutionResponse } from './types';
2/**
3 * Blockchain domain Resolution library - Resolution.
4 * @example
5 * ```
6 * let Resolution = new Resolution({blockchain: {ens: {url: 'https://mainnet.infura.io', network: 'mainnet'}}});
7 * let domain = brad.zil
8 * let Resolution = Resolution.address(domain);
9 * ```
10 */
11export default class Resolution {
12 readonly blockchain: Blockchain | boolean;
13 /**
14 * Resolution constructor
15 * @property blockchain - main configuration object
16 */
17 constructor({ blockchain }?: {
18 blockchain?: Blockchain;
19 });
20 /**
21 * Resolves the given domain
22 * @async
23 * @param domain - domain name to be resolved
24 * @returns A promise that resolves in an object
25 */
26 resolve(domain: string): Promise<ResolutionResponse>;
27 /**
28 * Resolves give domain name to a specific currency address if exists
29 * @async
30 * @param domain - domain name to be resolved
31 * @param currencyTicker - currency ticker like BTC, ETH, ZIL
32 * @returns A promise that resolves in an address or null
33 */
34 address(domain: string, currencyTicker: string): Promise<string | null>;
35 /**
36 * Resolves the ipfs hash configured for domain records on ZNS
37 * @param domain - domain name
38 * @throws ResolutionError
39 * @returns A Promise that resolves in ipfsHash
40 */
41 ipfsHash(domain: string): Promise<string>;
42 /**
43 * Resolves the ipfs redirect url for a supported domain records
44 * @param domain - domain name
45 * @throws ResolutionError
46 * @returns A Promise that resolves in redirect url
47 */
48 ipfsRedirect(domain: string): Promise<string>;
49 /**
50 * Resolves the ipfs email field from whois configurations
51 * @param domain - domain name
52 * @throws ResolutionError
53 * @returns A Promise that resolves in an email address configured for this domain whois
54 */
55 email(domain: string): Promise<string>;
56 /**
57 * Resolves given domain to a specific currency address or throws an error
58 * @param domain - domain name
59 * @param currencyTicker - currency ticker such as
60 * - ZIL
61 * - BTC
62 * - ETH
63 * @throws ResolutionError if address is not found
64 */
65 addressOrThrow(domain: string, currencyTicker: string): Promise<string>;
66 /**
67 * Owner of the domain
68 * @param domain - domain name
69 * @returns An owner address of the domain
70 */
71 owner(domain: string): Promise<string | null>;
72 /**
73 * This method is only for ens at the moment. Reverse the ens address to a ens registered domain name
74 * @async
75 * @param address - address you wish to reverse
76 * @param currencyTicker - currency ticker like BTC, ETH, ZIL
77 * @returns Domain name attached to this address
78 */
79 reverse(address: string, currencyTicker: string): Promise<string>;
80 /**
81 * Produce a namehash from supported naming service
82 * @param domain - domain name to be hashed
83 * @returns Namehash either for ENS or ZNS
84 */
85 namehash(domain: string): string;
86 /**
87 * Checks if the domain is in valid format
88 * @param domain - domain name to be checked
89 */
90 isSupportedDomain(domain: string): boolean;
91 /**
92 * Checks if the domain is supported by the specified network as well as if it is in valid format
93 * @param domain - domain name to be checked
94 */
95 isSupportedDomainInNetwork(domain: string): boolean;
96 /**
97 * Used internally to get the right method (ens or zns)
98 * @param domain - domain name
99 */
100 private getNamingMethod;
101 private getNamingMethodOrThrow;
102}
103export { Resolution };