UNPKG

3.61 kBTypeScriptView Raw
1import { SourceDefinition, NamicornResolution } from './types';
2import NamingService from './namingService';
3/**
4 * Class to support connection with Etherium naming service
5 * @param network - network string such as
6 * - mainnet
7 * - ropsten
8 * @param url - main api url such as
9 * - https://mainnet.infura.io
10 * @param registryAddress - address for a registry contract
11 */
12export default class Ens extends NamingService {
13 readonly network: string;
14 readonly url: string;
15 readonly registryAddress?: string;
16 private ensContract;
17 /**
18 * Source object describing the network naming service operates on
19 * @param source - if specified as a string will be used as main url, if omited then defaults are used
20 * @throws ConfigurationError - when either network or url is setup incorrectly
21 */
22 constructor(source?: string | boolean | SourceDefinition);
23 /**
24 * Checks if the domain is in valid format
25 * @param domain - domain name to be checked
26 */
27 isSupportedDomain(domain: string): boolean;
28 /**
29 * Checks if the current network is supported
30 */
31 isSupportedNetwork(): boolean;
32 /**
33 * Reverse the ens address to a ens registered domain name
34 * @async
35 * @param address - address you wish to reverse
36 * @param currencyTicker - currency ticker like BTC, ETH, ZIL
37 * @returns Domain name attached to this address
38 */
39 reverse(address: string, currencyTicker: string): Promise<string>;
40 /**
41 * Resolves domain to a specific cryptoAddress
42 * @param domain - domain name to be resolved
43 * @param currencyTicker - specific currency ticker such as
44 * - ZIL
45 * - BTC
46 * - ETH
47 * @returns A promise that resolves in a string
48 * @throws ResolutionError
49 */
50 address(domain: string, currencyTicker: string): Promise<string>;
51 /**
52 * Owner of the domain
53 * @param domain - domain name
54 * @returns An owner address of the domain
55 */
56 owner(domain: string): Promise<string | null>;
57 /**
58 * Resolves the given domain
59 * @async
60 * @param domain - domain name to be resolved
61 * @returns A promise that resolves in an object
62 */
63 resolve(domain: string): Promise<NamicornResolution | null>;
64 /**
65 * Produces ENS namehash
66 * @param domain - domain to be hashed
67 * @returns ENS namehash of a domain
68 */
69 namehash(domain: string): string;
70 /**
71 * Normalizes the source object based on type
72 */
73 protected normalizeSource(source: string | boolean | SourceDefinition): SourceDefinition;
74 /**
75 * This was done to make automated tests more configurable
76 */
77 private resolverCallToName;
78 /**
79 * This was done to make automated tests more configurable
80 */
81 private getResolver;
82 /**
83 * This was done to make automated tests more configurable
84 */
85 private getOwner;
86 /**
87 * This was done to make automated tests more configurable
88 */
89 private getResolutionInfo;
90 private getCoinType;
91 /**
92 * @param resolver - resolver address
93 * @param nodeHash - namehash of a domain name
94 */
95 private fetchAddress;
96 /**
97 * Look up for network from url provided
98 * @param url - main api url for blockchain
99 * @returns Network such as:
100 * - mainnet
101 * - testnet
102 */
103 private networkFromUrl;
104 /**
105 * Internal wrapper for ens method. Used to throw an error when ens is down
106 * @param method - method to be called
107 * @throws ResolutionError -> When blockchain is down
108 */
109 private callMethod;
110}