network.d.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /**
  2. * A **Network** encapsulates the various properties required to
  3. * interact with a specific chain.
  4. *
  5. * @_subsection: api/providers:Networks [networks]
  6. */
  7. import type { BigNumberish } from "../utils/index.js";
  8. import type { TransactionLike } from "../transaction/index.js";
  9. import type { NetworkPlugin } from "./plugins-network.js";
  10. /**
  11. * A Networkish can be used to allude to a Network, by specifing:
  12. * - a [[Network]] object
  13. * - a well-known (or registered) network name
  14. * - a well-known (or registered) chain ID
  15. * - an object with sufficient details to describe a network
  16. */
  17. export type Networkish = Network | number | bigint | string | {
  18. name?: string;
  19. chainId?: number;
  20. ensAddress?: string;
  21. ensNetwork?: number;
  22. };
  23. /**
  24. * A **Network** provides access to a chain's properties and allows
  25. * for plug-ins to extend functionality.
  26. */
  27. export declare class Network {
  28. #private;
  29. /**
  30. * Creates a new **Network** for %%name%% and %%chainId%%.
  31. */
  32. constructor(name: string, chainId: BigNumberish);
  33. /**
  34. * Returns a JSON-compatible representation of a Network.
  35. */
  36. toJSON(): any;
  37. /**
  38. * The network common name.
  39. *
  40. * This is the canonical name, as networks migh have multiple
  41. * names.
  42. */
  43. get name(): string;
  44. set name(value: string);
  45. /**
  46. * The network chain ID.
  47. */
  48. get chainId(): bigint;
  49. set chainId(value: BigNumberish);
  50. /**
  51. * Returns true if %%other%% matches this network. Any chain ID
  52. * must match, and if no chain ID is present, the name must match.
  53. *
  54. * This method does not currently check for additional properties,
  55. * such as ENS address or plug-in compatibility.
  56. */
  57. matches(other: Networkish): boolean;
  58. /**
  59. * Returns the list of plugins currently attached to this Network.
  60. */
  61. get plugins(): Array<NetworkPlugin>;
  62. /**
  63. * Attach a new %%plugin%% to this Network. The network name
  64. * must be unique, excluding any fragment.
  65. */
  66. attachPlugin(plugin: NetworkPlugin): this;
  67. /**
  68. * Return the plugin, if any, matching %%name%% exactly. Plugins
  69. * with fragments will not be returned unless %%name%% includes
  70. * a fragment.
  71. */
  72. getPlugin<T extends NetworkPlugin = NetworkPlugin>(name: string): null | T;
  73. /**
  74. * Gets a list of all plugins that match %%name%%, with otr without
  75. * a fragment.
  76. */
  77. getPlugins<T extends NetworkPlugin = NetworkPlugin>(basename: string): Array<T>;
  78. /**
  79. * Create a copy of this Network.
  80. */
  81. clone(): Network;
  82. /**
  83. * Compute the intrinsic gas required for a transaction.
  84. *
  85. * A GasCostPlugin can be attached to override the default
  86. * values.
  87. */
  88. computeIntrinsicGas(tx: TransactionLike): number;
  89. /**
  90. * Returns a new Network for the %%network%% name or chainId.
  91. */
  92. static from(network?: Networkish): Network;
  93. /**
  94. * Register %%nameOrChainId%% with a function which returns
  95. * an instance of a Network representing that chain.
  96. */
  97. static register(nameOrChainId: string | number | bigint, networkFunc: () => Network): void;
  98. }
  99. //# sourceMappingURL=network.d.ts.map