provider-browser.d.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { JsonRpcApiPollingProvider } from "./provider-jsonrpc.js";
  2. import type { JsonRpcError, JsonRpcPayload, JsonRpcResult, JsonRpcSigner } from "./provider-jsonrpc.js";
  3. import type { Network, Networkish } from "./network.js";
  4. /**
  5. * The interface to an [[link-eip-1193]] provider, which is a standard
  6. * used by most injected providers, which the [[BrowserProvider]] accepts
  7. * and exposes the API of.
  8. */
  9. export interface Eip1193Provider {
  10. /**
  11. * See [[link-eip-1193]] for details on this method.
  12. */
  13. request(request: {
  14. method: string;
  15. params?: Array<any> | Record<string, any>;
  16. }): Promise<any>;
  17. }
  18. /**
  19. * The possible additional events dispatched when using the ``"debug"``
  20. * event on a [[BrowserProvider]].
  21. */
  22. export type DebugEventBrowserProvider = {
  23. action: "sendEip1193Payload";
  24. payload: {
  25. method: string;
  26. params: Array<any>;
  27. };
  28. } | {
  29. action: "receiveEip1193Result";
  30. result: any;
  31. } | {
  32. action: "receiveEip1193Error";
  33. error: Error;
  34. };
  35. export type BrowserProviderOptions = {
  36. polling?: boolean;
  37. staticNetwork?: null | boolean | Network;
  38. cacheTimeout?: number;
  39. pollingInterval?: number;
  40. };
  41. /**
  42. * A **BrowserProvider** is intended to wrap an injected provider which
  43. * adheres to the [[link-eip-1193]] standard, which most (if not all)
  44. * currently do.
  45. */
  46. export declare class BrowserProvider extends JsonRpcApiPollingProvider {
  47. #private;
  48. /**
  49. * Connect to the %%ethereum%% provider, optionally forcing the
  50. * %%network%%.
  51. */
  52. constructor(ethereum: Eip1193Provider, network?: Networkish, _options?: BrowserProviderOptions);
  53. send(method: string, params: Array<any> | Record<string, any>): Promise<any>;
  54. _send(payload: JsonRpcPayload | Array<JsonRpcPayload>): Promise<Array<JsonRpcResult | JsonRpcError>>;
  55. getRpcError(payload: JsonRpcPayload, error: JsonRpcError): Error;
  56. /**
  57. * Resolves to ``true`` if the provider manages the %%address%%.
  58. */
  59. hasSigner(address: number | string): Promise<boolean>;
  60. getSigner(address?: number | string): Promise<JsonRpcSigner>;
  61. }
  62. //# sourceMappingURL=provider-browser.d.ts.map