UNPKG

5.02 kBTypeScriptView Raw
1/**
2 * ENS is a service which allows easy-to-remember names to map to
3 * network addresses.
4 *
5 * @_section: api/providers/ens-resolver:ENS Resolver [about-ens-rsolver]
6 */
7import type { BytesLike } from "../utils/index.js";
8import type { AbstractProvider, AbstractProviderPlugin } from "./abstract-provider.js";
9import type { Provider } from "./provider.js";
10/**
11 * The type of data found during a steip during avatar resolution.
12 */
13export type AvatarLinkageType = "name" | "avatar" | "!avatar" | "url" | "data" | "ipfs" | "erc721" | "erc1155" | "!erc721-caip" | "!erc1155-caip" | "!owner" | "owner" | "!balance" | "balance" | "metadata-url-base" | "metadata-url-expanded" | "metadata-url" | "!metadata-url" | "!metadata" | "metadata" | "!imageUrl" | "imageUrl-ipfs" | "imageUrl" | "!imageUrl-ipfs";
14/**
15 * An individual record for each step during avatar resolution.
16 */
17export interface AvatarLinkage {
18 /**
19 * The type of linkage.
20 */
21 type: AvatarLinkageType;
22 /**
23 * The linkage value.
24 */
25 value: string;
26}
27/**
28 * When resolving an avatar for an ENS name, there are many
29 * steps involved, fetching metadata, validating results, et cetera.
30 *
31 * Some applications may wish to analyse this data, or use this data
32 * to diagnose promblems, so an **AvatarResult** provides details of
33 * each completed step during avatar resolution.
34 */
35export interface AvatarResult {
36 /**
37 * How the [[url]] was arrived at, resolving the many steps required
38 * for an avatar URL.
39 */
40 linkage: Array<AvatarLinkage>;
41 /**
42 * The avatar URL or null if the avatar was not set, or there was
43 * an issue during validation (such as the address not owning the
44 * avatar or a metadata error).
45 */
46 url: null | string;
47}
48/**
49 * A provider plugin super-class for processing multicoin address types.
50 */
51export declare abstract class MulticoinProviderPlugin implements AbstractProviderPlugin {
52 /**
53 * The name.
54 */
55 readonly name: string;
56 /**
57 * Creates a new **MulticoinProviderPluing** for %%name%%.
58 */
59 constructor(name: string);
60 connect(proivder: Provider): MulticoinProviderPlugin;
61 /**
62 * Returns ``true`` if %%coinType%% is supported by this plugin.
63 */
64 supportsCoinType(coinType: number): boolean;
65 /**
66 * Resolves to the encoded %%address%% for %%coinType%%.
67 */
68 encodeAddress(coinType: number, address: string): Promise<string>;
69 /**
70 * Resolves to the decoded %%data%% for %%coinType%%.
71 */
72 decodeAddress(coinType: number, data: BytesLike): Promise<string>;
73}
74/**
75 * A **BasicMulticoinProviderPlugin** provides service for common
76 * coin types, which do not require additional libraries to encode or
77 * decode.
78 */
79export declare class BasicMulticoinProviderPlugin extends MulticoinProviderPlugin {
80 /**
81 * Creates a new **BasicMulticoinProviderPlugin**.
82 */
83 constructor();
84}
85/**
86 * A connected object to a resolved ENS name resolver, which can be
87 * used to query additional details.
88 */
89export declare class EnsResolver {
90 #private;
91 /**
92 * The connected provider.
93 */
94 provider: AbstractProvider;
95 /**
96 * The address of the resolver.
97 */
98 address: string;
99 /**
100 * The name this resolver was resolved against.
101 */
102 name: string;
103 constructor(provider: AbstractProvider, address: string, name: string);
104 /**
105 * Resolves to true if the resolver supports wildcard resolution.
106 */
107 supportsWildcard(): Promise<boolean>;
108 /**
109 * Resolves to the address for %%coinType%% or null if the
110 * provided %%coinType%% has not been configured.
111 */
112 getAddress(coinType?: number): Promise<null | string>;
113 /**
114 * Resolves to the EIP-634 text record for %%key%%, or ``null``
115 * if unconfigured.
116 */
117 getText(key: string): Promise<null | string>;
118 /**
119 * Rsolves to the content-hash or ``null`` if unconfigured.
120 */
121 getContentHash(): Promise<null | string>;
122 /**
123 * Resolves to the avatar url or ``null`` if the avatar is either
124 * unconfigured or incorrectly configured (e.g. references an NFT
125 * not owned by the address).
126 *
127 * If diagnosing issues with configurations, the [[_getAvatar]]
128 * method may be useful.
129 */
130 getAvatar(): Promise<null | string>;
131 /**
132 * When resolving an avatar, there are many steps involved, such
133 * fetching metadata and possibly validating ownership of an
134 * NFT.
135 *
136 * This method can be used to examine each step and the value it
137 * was working from.
138 */
139 _getAvatar(): Promise<AvatarResult>;
140 static getEnsAddress(provider: Provider): Promise<string>;
141 /**
142 * Resolve to the ENS resolver for %%name%% using %%provider%% or
143 * ``null`` if unconfigured.
144 */
145 static fromName(provider: AbstractProvider, name: string): Promise<null | EnsResolver>;
146}
147//# sourceMappingURL=ens-resolver.d.ts.map
\No newline at end of file