plugins-network.d.ts 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. import type { FeeData, Provider } from "./provider.js";
  2. import type { FetchRequest } from "../utils/fetch.js";
  3. /**
  4. * A **NetworkPlugin** provides additional functionality on a [[Network]].
  5. */
  6. export declare class NetworkPlugin {
  7. /**
  8. * The name of the plugin.
  9. *
  10. * It is recommended to use reverse-domain-notation, which permits
  11. * unique names with a known authority as well as hierarchal entries.
  12. */
  13. readonly name: string;
  14. /**
  15. * Creates a new **NetworkPlugin**.
  16. */
  17. constructor(name: string);
  18. /**
  19. * Creates a copy of this plugin.
  20. */
  21. clone(): NetworkPlugin;
  22. }
  23. /**
  24. * The gas cost parameters for a [[GasCostPlugin]].
  25. */
  26. export type GasCostParameters = {
  27. /**
  28. * The transactions base fee.
  29. */
  30. txBase?: number;
  31. /**
  32. * The fee for creating a new account.
  33. */
  34. txCreate?: number;
  35. /**
  36. * The fee per zero-byte in the data.
  37. */
  38. txDataZero?: number;
  39. /**
  40. * The fee per non-zero-byte in the data.
  41. */
  42. txDataNonzero?: number;
  43. /**
  44. * The fee per storage key in the [[link-eip-2930]] access list.
  45. */
  46. txAccessListStorageKey?: number;
  47. /**
  48. * The fee per address in the [[link-eip-2930]] access list.
  49. */
  50. txAccessListAddress?: number;
  51. };
  52. /**
  53. * A **GasCostPlugin** allows a network to provide alternative values when
  54. * computing the intrinsic gas required for a transaction.
  55. */
  56. export declare class GasCostPlugin extends NetworkPlugin implements GasCostParameters {
  57. /**
  58. * The block number to treat these values as valid from.
  59. *
  60. * This allows a hardfork to have updated values included as well as
  61. * mulutiple hardforks to be supported.
  62. */
  63. readonly effectiveBlock: number;
  64. /**
  65. * The transactions base fee.
  66. */
  67. readonly txBase: number;
  68. /**
  69. * The fee for creating a new account.
  70. */
  71. readonly txCreate: number;
  72. /**
  73. * The fee per zero-byte in the data.
  74. */
  75. readonly txDataZero: number;
  76. /**
  77. * The fee per non-zero-byte in the data.
  78. */
  79. readonly txDataNonzero: number;
  80. /**
  81. * The fee per storage key in the [[link-eip-2930]] access list.
  82. */
  83. readonly txAccessListStorageKey: number;
  84. /**
  85. * The fee per address in the [[link-eip-2930]] access list.
  86. */
  87. readonly txAccessListAddress: number;
  88. /**
  89. * Creates a new GasCostPlugin from %%effectiveBlock%% until the
  90. * latest block or another GasCostPlugin supercedes that block number,
  91. * with the associated %%costs%%.
  92. */
  93. constructor(effectiveBlock?: number, costs?: GasCostParameters);
  94. clone(): GasCostPlugin;
  95. }
  96. /**
  97. * An **EnsPlugin** allows a [[Network]] to specify the ENS Registry
  98. * Contract address and the target network to use when using that
  99. * contract.
  100. *
  101. * Various testnets have their own instance of the contract to use, but
  102. * in general, the mainnet instance supports multi-chain addresses and
  103. * should be used.
  104. */
  105. export declare class EnsPlugin extends NetworkPlugin {
  106. /**
  107. * The ENS Registrty Contract address.
  108. */
  109. readonly address: string;
  110. /**
  111. * The chain ID that the ENS contract lives on.
  112. */
  113. readonly targetNetwork: number;
  114. /**
  115. * Creates a new **EnsPlugin** connected to %%address%% on the
  116. * %%targetNetwork%%. The default ENS address and mainnet is used
  117. * if unspecified.
  118. */
  119. constructor(address?: null | string, targetNetwork?: null | number);
  120. clone(): EnsPlugin;
  121. }
  122. /**
  123. * A **FeeDataNetworkPlugin** allows a network to provide and alternate
  124. * means to specify its fee data.
  125. *
  126. * For example, a network which does not support [[link-eip-1559]] may
  127. * choose to use a Gas Station site to approximate the gas price.
  128. */
  129. export declare class FeeDataNetworkPlugin extends NetworkPlugin {
  130. #private;
  131. /**
  132. * The fee data function provided to the constructor.
  133. */
  134. get feeDataFunc(): (provider: Provider) => Promise<FeeData>;
  135. /**
  136. * Creates a new **FeeDataNetworkPlugin**.
  137. */
  138. constructor(feeDataFunc: (provider: Provider) => Promise<FeeData>);
  139. /**
  140. * Resolves to the fee data.
  141. */
  142. getFeeData(provider: Provider): Promise<FeeData>;
  143. clone(): FeeDataNetworkPlugin;
  144. }
  145. export declare class FetchUrlFeeDataNetworkPlugin extends NetworkPlugin {
  146. #private;
  147. /**
  148. * The URL to initialize the FetchRequest with in %%processFunc%%.
  149. */
  150. get url(): string;
  151. /**
  152. * The callback to use when computing the FeeData.
  153. */
  154. get processFunc(): (f: () => Promise<FeeData>, p: Provider, r: FetchRequest) => Promise<{
  155. gasPrice?: null | bigint;
  156. maxFeePerGas?: null | bigint;
  157. maxPriorityFeePerGas?: null | bigint;
  158. }>;
  159. /**
  160. * Creates a new **FetchUrlFeeDataNetworkPlugin** which will
  161. * be used when computing the fee data for the network.
  162. */
  163. constructor(url: string, processFunc: (f: () => Promise<FeeData>, p: Provider, r: FetchRequest) => Promise<{
  164. gasPrice?: null | bigint;
  165. maxFeePerGas?: null | bigint;
  166. maxPriorityFeePerGas?: null | bigint;
  167. }>);
  168. clone(): FetchUrlFeeDataNetworkPlugin;
  169. }
  170. //# sourceMappingURL=plugins-network.d.ts.map