1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | import { AbiCoder } from "./abi-coder.js";
|
13 | import { checkResultErrors, Result } from "./coders/abstract-coder.js";
|
14 | import { ConstructorFragment, ErrorFragment, EventFragment, FallbackFragment, Fragment, FunctionFragment, ParamType } from "./fragments.js";
|
15 | import { Typed } from "./typed.js";
|
16 | import type { BigNumberish, BytesLike, CallExceptionError, CallExceptionTransaction } from "../utils/index.js";
|
17 | import type { JsonFragment } from "./fragments.js";
|
18 | export { checkResultErrors, Result };
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | export declare class LogDescription {
|
24 | |
25 |
|
26 |
|
27 | readonly fragment: EventFragment;
|
28 | |
29 |
|
30 |
|
31 | readonly name: string;
|
32 | |
33 |
|
34 |
|
35 | readonly signature: string;
|
36 | |
37 |
|
38 |
|
39 | readonly topic: string;
|
40 | |
41 |
|
42 |
|
43 | readonly args: Result;
|
44 | |
45 |
|
46 |
|
47 | constructor(fragment: EventFragment, topic: string, args: Result);
|
48 | }
|
49 | /**
|
50 | * When using the [[Interface-parseTransaction]] to automatically match
|
51 | * a transaction data to its function for parsing,
|
52 | * a **TransactionDescription** is returned.
|
53 | */
|
54 | export declare class TransactionDescription {
|
55 | |
56 |
|
57 |
|
58 | readonly fragment: FunctionFragment;
|
59 | |
60 |
|
61 |
|
62 | readonly name: string;
|
63 | |
64 |
|
65 |
|
66 | readonly args: Result;
|
67 | |
68 |
|
69 |
|
70 | readonly signature: string;
|
71 | |
72 |
|
73 |
|
74 | readonly selector: string;
|
75 | |
76 |
|
77 |
|
78 | readonly value: bigint;
|
79 | |
80 |
|
81 |
|
82 | constructor(fragment: FunctionFragment, selector: string, args: Result, value: bigint);
|
83 | }
|
84 | /**
|
85 | * When using the [[Interface-parseError]] to automatically match an
|
86 | * error for a call result for parsing, an **ErrorDescription** is returned.
|
87 | */
|
88 | export declare class ErrorDescription {
|
89 | |
90 |
|
91 |
|
92 | readonly fragment: ErrorFragment;
|
93 | |
94 |
|
95 |
|
96 | readonly name: string;
|
97 | |
98 |
|
99 |
|
100 | readonly args: Result;
|
101 | |
102 |
|
103 |
|
104 | readonly signature: string;
|
105 | |
106 |
|
107 |
|
108 | readonly selector: string;
|
109 | |
110 |
|
111 |
|
112 | constructor(fragment: ErrorFragment, selector: string, args: Result);
|
113 | }
|
114 | /**
|
115 | * An **Indexed** is used as a value when a value that does not
|
116 | * fit within a topic (i.e. not a fixed-length, 32-byte type). It
|
117 | * is the ``keccak256`` of the value, and used for types such as
|
118 | * arrays, tuples, bytes and strings.
|
119 | */
|
120 | export declare class Indexed {
|
121 | |
122 |
|
123 |
|
124 | readonly hash: null | string;
|
125 | |
126 |
|
127 |
|
128 | readonly _isIndexed: boolean;
|
129 | |
130 |
|
131 |
|
132 |
|
133 |
|
134 | static isIndexed(value: any): value is Indexed;
|
135 | |
136 |
|
137 |
|
138 | constructor(hash: null | string);
|
139 | }
|
140 | /**
|
141 | * An **InterfaceAbi** may be any supported ABI format.
|
142 | *
|
143 | * A string is expected to be a JSON string, which will be parsed
|
144 | * using ``JSON.parse``. This means that the value **must** be a valid
|
145 | * JSON string, with no stray commas, etc.
|
146 | *
|
147 | * An array may contain any combination of:
|
148 | * - Human-Readable fragments
|
149 | * - Parsed JSON fragment
|
150 | * - [[Fragment]] instances
|
151 | *
|
152 | * A **Human-Readable Fragment** is a string which resembles a Solidity
|
153 | * signature and is introduced in [this blog entry](link-ricmoo-humanreadableabi).
|
154 | * For example, ``function balanceOf(address) view returns (uint)``.
|
155 | *
|
156 | * A **Parsed JSON Fragment** is a JavaScript Object desribed in the
|
157 | * [Solidity documentation](link-solc-jsonabi).
|
158 | */
|
159 | export type InterfaceAbi = string | ReadonlyArray<Fragment | JsonFragment | string>;
|
160 | /**
|
161 | * An Interface abstracts many of the low-level details for
|
162 | * encoding and decoding the data on the blockchain.
|
163 | *
|
164 | * An ABI provides information on how to encode data to send to
|
165 | * a Contract, how to decode the results and events and how to
|
166 | * interpret revert errors.
|
167 | *
|
168 | * The ABI can be specified by [any supported format](InterfaceAbi).
|
169 | */
|
170 | export declare class Interface {
|
171 | #private;
|
172 | |
173 |
|
174 |
|
175 | readonly fragments: ReadonlyArray<Fragment>;
|
176 | |
177 |
|
178 |
|
179 | readonly deploy: ConstructorFragment;
|
180 | |
181 |
|
182 |
|
183 | readonly fallback: null | FallbackFragment;
|
184 | |
185 |
|
186 |
|
187 | readonly receive: boolean;
|
188 | |
189 |
|
190 |
|
191 | constructor(fragments: InterfaceAbi);
|
192 | /**
|
193 | * Returns the entire Human-Readable ABI, as an array of
|
194 | * signatures, optionally as %%minimal%% strings, which
|
195 | * removes parameter names and unneceesary spaces.
|
196 | */
|
197 | format(minimal?: boolean): Array<string>;
|
198 | /**
|
199 | * Return the JSON-encoded ABI. This is the format Solidiy
|
200 | * returns.
|
201 | */
|
202 | formatJson(): string;
|
203 | /**
|
204 | * The ABI coder that will be used to encode and decode binary
|
205 | * data.
|
206 | */
|
207 | getAbiCoder(): AbiCoder;
|
208 | /**
|
209 | * Get the function name for %%key%%, which may be a function selector,
|
210 | * function name or function signature that belongs to the ABI.
|
211 | */
|
212 | getFunctionName(key: string): string;
|
213 | /**
|
214 | * Returns true if %%key%% (a function selector, function name or
|
215 | * function signature) is present in the ABI.
|
216 | *
|
217 | * In the case of a function name, the name may be ambiguous, so
|
218 | * accessing the [[FunctionFragment]] may require refinement.
|
219 | */
|
220 | hasFunction(key: string): boolean;
|
221 | /**
|
222 | * Get the [[FunctionFragment]] for %%key%%, which may be a function
|
223 | * selector, function name or function signature that belongs to the ABI.
|
224 | *
|
225 | * If %%values%% is provided, it will use the Typed API to handle
|
226 | * ambiguous cases where multiple functions match by name.
|
227 | *
|
228 | * If the %%key%% and %%values%% do not refine to a single function in
|
229 | * the ABI, this will throw.
|
230 | */
|
231 | getFunction(key: string, values?: Array<any | Typed>): null | FunctionFragment;
|
232 | /**
|
233 | * Iterate over all functions, calling %%callback%%, sorted by their name.
|
234 | */
|
235 | forEachFunction(callback: (func: FunctionFragment, index: number) => void): void;
|
236 | /**
|
237 | * Get the event name for %%key%%, which may be a topic hash,
|
238 | * event name or event signature that belongs to the ABI.
|
239 | */
|
240 | getEventName(key: string): string;
|
241 | /**
|
242 | * Returns true if %%key%% (an event topic hash, event name or
|
243 | * event signature) is present in the ABI.
|
244 | *
|
245 | * In the case of an event name, the name may be ambiguous, so
|
246 | * accessing the [[EventFragment]] may require refinement.
|
247 | */
|
248 | hasEvent(key: string): boolean;
|
249 | /**
|
250 | * Get the [[EventFragment]] for %%key%%, which may be a topic hash,
|
251 | * event name or event signature that belongs to the ABI.
|
252 | *
|
253 | * If %%values%% is provided, it will use the Typed API to handle
|
254 | * ambiguous cases where multiple events match by name.
|
255 | *
|
256 | * If the %%key%% and %%values%% do not refine to a single event in
|
257 | * the ABI, this will throw.
|
258 | */
|
259 | getEvent(key: string, values?: Array<any | Typed>): null | EventFragment;
|
260 | /**
|
261 | * Iterate over all events, calling %%callback%%, sorted by their name.
|
262 | */
|
263 | forEachEvent(callback: (func: EventFragment, index: number) => void): void;
|
264 | /**
|
265 | * Get the [[ErrorFragment]] for %%key%%, which may be an error
|
266 | * selector, error name or error signature that belongs to the ABI.
|
267 | *
|
268 | * If %%values%% is provided, it will use the Typed API to handle
|
269 | * ambiguous cases where multiple errors match by name.
|
270 | *
|
271 | * If the %%key%% and %%values%% do not refine to a single error in
|
272 | * the ABI, this will throw.
|
273 | */
|
274 | getError(key: string, values?: Array<any | Typed>): null | ErrorFragment;
|
275 | /**
|
276 | * Iterate over all errors, calling %%callback%%, sorted by their name.
|
277 | */
|
278 | forEachError(callback: (func: ErrorFragment, index: number) => void): void;
|
279 | _decodeParams(params: ReadonlyArray<ParamType>, data: BytesLike): Result;
|
280 | _encodeParams(params: ReadonlyArray<ParamType>, values: ReadonlyArray<any>): string;
|
281 | /**
|
282 | * Encodes a ``tx.data`` object for deploying the Contract with
|
283 | * the %%values%% as the constructor arguments.
|
284 | */
|
285 | encodeDeploy(values?: ReadonlyArray<any>): string;
|
286 | /**
|
287 | * Decodes the result %%data%% (e.g. from an ``eth_call``) for the
|
288 | * specified error (see [[getError]] for valid values for
|
289 | * %%key%%).
|
290 | *
|
291 | * Most developers should prefer the [[parseCallResult]] method instead,
|
292 | * which will automatically detect a ``CALL_EXCEPTION`` and throw the
|
293 | * corresponding error.
|
294 | */
|
295 | decodeErrorResult(fragment: ErrorFragment | string, data: BytesLike): Result;
|
296 | /**
|
297 | * Encodes the transaction revert data for a call result that
|
298 | * reverted from the the Contract with the sepcified %%error%%
|
299 | * (see [[getError]] for valid values for %%fragment%%) with the %%values%%.
|
300 | *
|
301 | * This is generally not used by most developers, unless trying to mock
|
302 | * a result from a Contract.
|
303 | */
|
304 | encodeErrorResult(fragment: ErrorFragment | string, values?: ReadonlyArray<any>): string;
|
305 | /**
|
306 | * Decodes the %%data%% from a transaction ``tx.data`` for
|
307 | * the function specified (see [[getFunction]] for valid values
|
308 | * for %%fragment%%).
|
309 | *
|
310 | * Most developers should prefer the [[parseTransaction]] method
|
311 | * instead, which will automatically detect the fragment.
|
312 | */
|
313 | decodeFunctionData(fragment: FunctionFragment | string, data: BytesLike): Result;
|
314 | /**
|
315 | * Encodes the ``tx.data`` for a transaction that calls the function
|
316 | * specified (see [[getFunction]] for valid values for %%fragment%%) with
|
317 | * the %%values%%.
|
318 | */
|
319 | encodeFunctionData(fragment: FunctionFragment | string, values?: ReadonlyArray<any>): string;
|
320 | /**
|
321 | * Decodes the result %%data%% (e.g. from an ``eth_call``) for the
|
322 | * specified function (see [[getFunction]] for valid values for
|
323 | * %%key%%).
|
324 | *
|
325 | * Most developers should prefer the [[parseCallResult]] method instead,
|
326 | * which will automatically detect a ``CALL_EXCEPTION`` and throw the
|
327 | * corresponding error.
|
328 | */
|
329 | decodeFunctionResult(fragment: FunctionFragment | string, data: BytesLike): Result;
|
330 | makeError(_data: BytesLike, tx: CallExceptionTransaction): CallExceptionError;
|
331 | /**
|
332 | * Encodes the result data (e.g. from an ``eth_call``) for the
|
333 | * specified function (see [[getFunction]] for valid values
|
334 | * for %%fragment%%) with %%values%%.
|
335 | *
|
336 | * This is generally not used by most developers, unless trying to mock
|
337 | * a result from a Contract.
|
338 | */
|
339 | encodeFunctionResult(fragment: FunctionFragment | string, values?: ReadonlyArray<any>): string;
|
340 | encodeFilterTopics(fragment: EventFragment | string, values: ReadonlyArray<any>): Array<null | string | Array<string>>;
|
341 | encodeEventLog(fragment: EventFragment | string, values: ReadonlyArray<any>): {
|
342 | data: string;
|
343 | topics: Array<string>;
|
344 | };
|
345 | decodeEventLog(fragment: EventFragment | string, data: BytesLike, topics?: ReadonlyArray<string>): Result;
|
346 | /**
|
347 | * Parses a transaction, finding the matching function and extracts
|
348 | * the parameter values along with other useful function details.
|
349 | *
|
350 | * If the matching function cannot be found, return null.
|
351 | */
|
352 | parseTransaction(tx: {
|
353 | data: string;
|
354 | value?: BigNumberish;
|
355 | }): null | TransactionDescription;
|
356 | parseCallResult(data: BytesLike): Result;
|
357 | /**
|
358 | * Parses a receipt log, finding the matching event and extracts
|
359 | * the parameter values along with other useful event details.
|
360 | *
|
361 | * If the matching event cannot be found, returns null.
|
362 | */
|
363 | parseLog(log: {
|
364 | topics: ReadonlyArray<string>;
|
365 | data: string;
|
366 | }): null | LogDescription;
|
367 | /**
|
368 | * Parses a revert data, finding the matching error and extracts
|
369 | * the parameter values along with other useful error details.
|
370 | *
|
371 | * If the matching error cannot be found, returns null.
|
372 | */
|
373 | parseError(data: BytesLike): null | ErrorDescription;
|
374 | /**
|
375 | * Creates a new [[Interface]] from the ABI %%value%%.
|
376 | *
|
377 | * The %%value%% may be provided as an existing [[Interface]] object,
|
378 | * a JSON-encoded ABI or any Human-Readable ABI format.
|
379 | */
|
380 | static from(value: InterfaceAbi | Interface): Interface;
|
381 | }
|
382 | //# sourceMappingURL=interface.d.ts.map |
\ | No newline at end of file |