UNPKG

6.86 kBTypeScriptView Raw
1import type { EventFragment, FunctionFragment, Result, Typed } from "../abi/index.js";
2import type { TransactionRequest, PreparedTransactionRequest, TopicFilter } from "../providers/index.js";
3import type { ContractTransactionResponse } from "./wrappers.js";
4/**
5 * The name for an event used for subscribing to Contract events.
6 *
7 * **``string``** - An event by name. The event must be non-ambiguous.
8 * The parameters will be dereferenced when passed into the listener.
9 *
10 * [[ContractEvent]] - A filter from the ``contract.filters``, which will
11 * pass only the EventPayload as a single parameter, which includes a
12 * ``.signature`` property that can be used to further filter the event.
13 *
14 * [[TopicFilter]] - A filter defined using the standard Ethereum API
15 * which provides the specific topic hash or topic hashes to watch for along
16 * with any additional values to filter by. This will only pass a single
17 * parameter to the listener, the EventPayload which will include additional
18 * details to refine by, such as the event name and signature.
19 *
20 * [[DeferredTopicFilter]] - A filter created by calling a [[ContractEvent]]
21 * with parameters, which will create a filter for a specific event
22 * signautre and dereference each parameter when calling the listener.
23 */
24export type ContractEventName = string | ContractEvent | TopicFilter | DeferredTopicFilter;
25/**
26 * A Contract with no method constraints.
27 */
28export interface ContractInterface {
29 [name: string]: BaseContractMethod;
30}
31/**
32 * When creating a filter using the ``contract.filters``, this is returned.
33 */
34export interface DeferredTopicFilter {
35 getTopicFilter(): Promise<TopicFilter>;
36 fragment: EventFragment;
37}
38/**
39 * When populating a transaction this type is returned.
40 */
41export interface ContractTransaction extends PreparedTransactionRequest {
42 /**
43 * The target address.
44 */
45 to: string;
46 /**
47 * The transaction data.
48 */
49 data: string;
50 /**
51 * The from address, if any.
52 */
53 from?: string;
54}
55/**
56 * A deployment transaction for a contract.
57 */
58export interface ContractDeployTransaction extends Omit<ContractTransaction, "to"> {
59}
60/**
61 * The overrides for a contract transaction.
62 */
63export interface Overrides extends Omit<TransactionRequest, "to" | "data"> {
64}
65/**
66 * Arguments to a Contract method can always include an additional and
67 * optional overrides parameter.
68 *
69 * @_ignore:
70 */
71export type PostfixOverrides<A extends Array<any>> = A | [...A, Overrides];
72/**
73 * Arguments to a Contract method can always include an additional and
74 * optional overrides parameter, and each parameter can optionally be
75 * [[Typed]].
76 *
77 * @_ignore:
78 */
79export type ContractMethodArgs<A extends Array<any>> = PostfixOverrides<{
80 [I in keyof A]-?: A[I] | Typed;
81}>;
82/**
83 * A Contract method can be called directly, or used in various ways.
84 */
85export interface BaseContractMethod<A extends Array<any> = Array<any>, R = any, D extends R | ContractTransactionResponse = R | ContractTransactionResponse> {
86 (...args: ContractMethodArgs<A>): Promise<D>;
87 /**
88 * The name of the Contract method.
89 */
90 name: string;
91 /**
92 * The fragment of the Contract method. This will throw on ambiguous
93 * method names.
94 */
95 fragment: FunctionFragment;
96 /**
97 * Returns the fragment constrained by %%args%%. This can be used to
98 * resolve ambiguous method names.
99 */
100 getFragment(...args: ContractMethodArgs<A>): FunctionFragment;
101 /**
102 * Returns a populated transaction that can be used to perform the
103 * contract method with %%args%%.
104 */
105 populateTransaction(...args: ContractMethodArgs<A>): Promise<ContractTransaction>;
106 /**
107 * Call the contract method with %%args%% and return the value.
108 *
109 * If the return value is a single type, it will be dereferenced and
110 * returned directly, otherwise the full Result will be returned.
111 */
112 staticCall(...args: ContractMethodArgs<A>): Promise<R>;
113 /**
114 * Send a transaction for the contract method with %%args%%.
115 */
116 send(...args: ContractMethodArgs<A>): Promise<ContractTransactionResponse>;
117 /**
118 * Estimate the gas to send the contract method with %%args%%.
119 */
120 estimateGas(...args: ContractMethodArgs<A>): Promise<bigint>;
121 /**
122 * Call the contract method with %%args%% and return the Result
123 * without any dereferencing.
124 */
125 staticCallResult(...args: ContractMethodArgs<A>): Promise<Result>;
126}
127/**
128 * A contract method on a Contract.
129 */
130export interface ContractMethod<A extends Array<any> = Array<any>, R = any, D extends R | ContractTransactionResponse = R | ContractTransactionResponse> extends BaseContractMethod<A, R, D> {
131}
132/**
133 * A pure of view method on a Contract.
134 */
135export interface ConstantContractMethod<A extends Array<any>, R = any> extends ContractMethod<A, R, R> {
136}
137/**
138 * Each argument of an event is nullable (to indicate matching //any//.
139 *
140 * @_ignore:
141 */
142export type ContractEventArgs<A extends Array<any>> = {
143 [I in keyof A]?: A[I] | Typed | null;
144};
145export interface ContractEvent<A extends Array<any> = Array<any>> {
146 (...args: ContractEventArgs<A>): DeferredTopicFilter;
147 /**
148 * The name of the Contract event.
149 */
150 name: string;
151 /**
152 * The fragment of the Contract event. This will throw on ambiguous
153 * method names.
154 */
155 fragment: EventFragment;
156 /**
157 * Returns the fragment constrained by %%args%%. This can be used to
158 * resolve ambiguous event names.
159 */
160 getFragment(...args: ContractEventArgs<A>): EventFragment;
161}
162/**
163 * A Fallback or Receive function on a Contract.
164 */
165export interface WrappedFallback {
166 (overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransactionResponse>;
167 /**
168 * Returns a populated transaction that can be used to perform the
169 * fallback method.
170 *
171 * For non-receive fallback, ``data`` may be overridden.
172 */
173 populateTransaction(overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransaction>;
174 /**
175 * Call the contract fallback and return the result.
176 *
177 * For non-receive fallback, ``data`` may be overridden.
178 */
179 staticCall(overrides?: Omit<TransactionRequest, "to">): Promise<string>;
180 /**
181 * Send a transaction to the contract fallback.
182 *
183 * For non-receive fallback, ``data`` may be overridden.
184 */
185 send(overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransactionResponse>;
186 /**
187 * Estimate the gas to send a transaction to the contract fallback.
188 *
189 * For non-receive fallback, ``data`` may be overridden.
190 */
191 estimateGas(overrides?: Omit<TransactionRequest, "to">): Promise<bigint>;
192}
193//# sourceMappingURL=types.d.ts.map
\No newline at end of file