index.d.ts 1.1 KB

123456789101112131415161718192021222324252627282930
  1. interface EthereumProvider {
  2. isMetaMask?: boolean;
  3. }
  4. declare global {
  5. interface Window {
  6. ethereum?: EthereumProvider;
  7. }
  8. }
  9. export = detectEthereumProvider;
  10. /**
  11. * Returns a Promise that resolves to the value of window.ethereum if it is
  12. * set within the given timeout, or null.
  13. * The Promise will not reject, but an error will be thrown if invalid options
  14. * are provided.
  15. *
  16. * @param options - Options bag.
  17. * @param options.mustBeMetaMask - Whether to only look for MetaMask providers.
  18. * Default: false
  19. * @param options.silent - Whether to silence console errors. Does not affect
  20. * thrown errors. Default: false
  21. * @param options.timeout - Milliseconds to wait for 'ethereum#initialized' to
  22. * be dispatched. Default: 3000
  23. * @returns A Promise that resolves with the Provider if it is detected within
  24. * given timeout, otherwise null.
  25. */
  26. declare function detectEthereumProvider({ mustBeMetaMask, silent, timeout, }?: {
  27. mustBeMetaMask?: boolean | undefined;
  28. silent?: boolean | undefined;
  29. timeout?: number | undefined;
  30. }): Promise<unknown>;