contract.d.ts 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. import { Interface } from "../abi/index.js";
  2. import { Log, TransactionResponse } from "../providers/provider.js";
  3. import { ContractTransactionResponse, EventLog } from "./wrappers.js";
  4. import type { EventFragment, FunctionFragment, InterfaceAbi, ParamType } from "../abi/index.js";
  5. import type { Addressable } from "../address/index.js";
  6. import type { EventEmitterable, Listener } from "../utils/index.js";
  7. import type { BlockTag, ContractRunner } from "../providers/index.js";
  8. import type { ContractEventName, ContractInterface, ContractMethod, ContractEvent, ContractTransaction, WrappedFallback } from "./types.js";
  9. /**
  10. * @_ignore:
  11. */
  12. export declare function copyOverrides<O extends string = "data" | "to">(arg: any, allowed?: Array<string>): Promise<Omit<ContractTransaction, O>>;
  13. /**
  14. * @_ignore:
  15. */
  16. export declare function resolveArgs(_runner: null | ContractRunner, inputs: ReadonlyArray<ParamType>, args: Array<any>): Promise<Array<any>>;
  17. declare const internal: unique symbol;
  18. export declare class BaseContract implements Addressable, EventEmitterable<ContractEventName> {
  19. /**
  20. * The target to connect to.
  21. *
  22. * This can be an address, ENS name or any [[Addressable]], such as
  23. * another contract. To get the resovled address, use the ``getAddress``
  24. * method.
  25. */
  26. readonly target: string | Addressable;
  27. /**
  28. * The contract Interface.
  29. */
  30. readonly interface: Interface;
  31. /**
  32. * The connected runner. This is generally a [[Provider]] or a
  33. * [[Signer]], which dictates what operations are supported.
  34. *
  35. * For example, a **Contract** connected to a [[Provider]] may
  36. * only execute read-only operations.
  37. */
  38. readonly runner: null | ContractRunner;
  39. /**
  40. * All the Events available on this contract.
  41. */
  42. readonly filters: Record<string, ContractEvent>;
  43. /**
  44. * @_ignore:
  45. */
  46. readonly [internal]: any;
  47. /**
  48. * The fallback or receive function if any.
  49. */
  50. readonly fallback: null | WrappedFallback;
  51. /**
  52. * Creates a new contract connected to %%target%% with the %%abi%% and
  53. * optionally connected to a %%runner%% to perform operations on behalf
  54. * of.
  55. */
  56. constructor(target: string | Addressable, abi: Interface | InterfaceAbi, runner?: null | ContractRunner, _deployTx?: null | TransactionResponse);
  57. /**
  58. * Return a new Contract instance with the same target and ABI, but
  59. * a different %%runner%%.
  60. */
  61. connect(runner: null | ContractRunner): BaseContract;
  62. /**
  63. * Return a new Contract instance with the same ABI and runner, but
  64. * a different %%target%%.
  65. */
  66. attach(target: string | Addressable): BaseContract;
  67. /**
  68. * Return the resolved address of this Contract.
  69. */
  70. getAddress(): Promise<string>;
  71. /**
  72. * Return the deployed bytecode or null if no bytecode is found.
  73. */
  74. getDeployedCode(): Promise<null | string>;
  75. /**
  76. * Resolve to this Contract once the bytecode has been deployed, or
  77. * resolve immediately if already deployed.
  78. */
  79. waitForDeployment(): Promise<this>;
  80. /**
  81. * Return the transaction used to deploy this contract.
  82. *
  83. * This is only available if this instance was returned from a
  84. * [[ContractFactory]].
  85. */
  86. deploymentTransaction(): null | ContractTransactionResponse;
  87. /**
  88. * Return the function for a given name. This is useful when a contract
  89. * method name conflicts with a JavaScript name such as ``prototype`` or
  90. * when using a Contract programatically.
  91. */
  92. getFunction<T extends ContractMethod = ContractMethod>(key: string | FunctionFragment): T;
  93. /**
  94. * Return the event for a given name. This is useful when a contract
  95. * event name conflicts with a JavaScript name such as ``prototype`` or
  96. * when using a Contract programatically.
  97. */
  98. getEvent(key: string | EventFragment): ContractEvent;
  99. /**
  100. * @_ignore:
  101. */
  102. queryTransaction(hash: string): Promise<Array<EventLog>>;
  103. /**
  104. * Provide historic access to event data for %%event%% in the range
  105. * %%fromBlock%% (default: ``0``) to %%toBlock%% (default: ``"latest"``)
  106. * inclusive.
  107. */
  108. queryFilter(event: ContractEventName, fromBlock?: BlockTag, toBlock?: BlockTag): Promise<Array<EventLog | Log>>;
  109. /**
  110. * Add an event %%listener%% for the %%event%%.
  111. */
  112. on(event: ContractEventName, listener: Listener): Promise<this>;
  113. /**
  114. * Add an event %%listener%% for the %%event%%, but remove the listener
  115. * after it is fired once.
  116. */
  117. once(event: ContractEventName, listener: Listener): Promise<this>;
  118. /**
  119. * Emit an %%event%% calling all listeners with %%args%%.
  120. *
  121. * Resolves to ``true`` if any listeners were called.
  122. */
  123. emit(event: ContractEventName, ...args: Array<any>): Promise<boolean>;
  124. /**
  125. * Resolves to the number of listeners of %%event%% or the total number
  126. * of listeners if unspecified.
  127. */
  128. listenerCount(event?: ContractEventName): Promise<number>;
  129. /**
  130. * Resolves to the listeners subscribed to %%event%% or all listeners
  131. * if unspecified.
  132. */
  133. listeners(event?: ContractEventName): Promise<Array<Listener>>;
  134. /**
  135. * Remove the %%listener%% from the listeners for %%event%% or remove
  136. * all listeners if unspecified.
  137. */
  138. off(event: ContractEventName, listener?: Listener): Promise<this>;
  139. /**
  140. * Remove all the listeners for %%event%% or remove all listeners if
  141. * unspecified.
  142. */
  143. removeAllListeners(event?: ContractEventName): Promise<this>;
  144. /**
  145. * Alias for [on].
  146. */
  147. addListener(event: ContractEventName, listener: Listener): Promise<this>;
  148. /**
  149. * Alias for [off].
  150. */
  151. removeListener(event: ContractEventName, listener: Listener): Promise<this>;
  152. /**
  153. * Create a new Class for the %%abi%%.
  154. */
  155. static buildClass<T = ContractInterface>(abi: Interface | InterfaceAbi): new (target: string, runner?: null | ContractRunner) => BaseContract & Omit<T, keyof BaseContract>;
  156. /**
  157. * Create a new BaseContract with a specified Interface.
  158. */
  159. static from<T = ContractInterface>(target: string, abi: Interface | InterfaceAbi, runner?: null | ContractRunner): BaseContract & Omit<T, keyof BaseContract>;
  160. }
  161. declare const Contract_base: new (target: string | Addressable, abi: Interface | InterfaceAbi, runner?: ContractRunner | null | undefined) => BaseContract & Omit<ContractInterface, keyof BaseContract>;
  162. /**
  163. * A [[BaseContract]] with no type guards on its methods or events.
  164. */
  165. export declare class Contract extends Contract_base {
  166. }
  167. export {};
  168. //# sourceMappingURL=contract.d.ts.map