checks.d.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import type { Addressable, AddressLike, NameResolver } from "./index.js";
  2. /**
  3. * Returns true if %%value%% is an object which implements the
  4. * [[Addressable]] interface.
  5. *
  6. * @example:
  7. * // Wallets and AbstractSigner sub-classes
  8. * isAddressable(Wallet.createRandom())
  9. * //_result:
  10. *
  11. * // Contracts
  12. * contract = new Contract("dai.tokens.ethers.eth", [ ], provider)
  13. * isAddressable(contract)
  14. * //_result:
  15. */
  16. export declare function isAddressable(value: any): value is Addressable;
  17. /**
  18. * Returns true if %%value%% is a valid address.
  19. *
  20. * @example:
  21. * // Valid address
  22. * isAddress("0x8ba1f109551bD432803012645Ac136ddd64DBA72")
  23. * //_result:
  24. *
  25. * // Valid ICAP address
  26. * isAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36")
  27. * //_result:
  28. *
  29. * // Invalid checksum
  30. * isAddress("0x8Ba1f109551bD432803012645Ac136ddd64DBa72")
  31. * //_result:
  32. *
  33. * // Invalid ICAP checksum
  34. * isAddress("0x8Ba1f109551bD432803012645Ac136ddd64DBA72")
  35. * //_result:
  36. *
  37. * // Not an address (an ENS name requires a provided and an
  38. * // asynchronous API to access)
  39. * isAddress("ricmoo.eth")
  40. * //_result:
  41. */
  42. export declare function isAddress(value: any): value is string;
  43. /**
  44. * Resolves to an address for the %%target%%, which may be any
  45. * supported address type, an [[Addressable]] or a Promise which
  46. * resolves to an address.
  47. *
  48. * If an ENS name is provided, but that name has not been correctly
  49. * configured a [[UnconfiguredNameError]] is thrown.
  50. *
  51. * @example:
  52. * addr = "0x6B175474E89094C44Da98b954EedeAC495271d0F"
  53. *
  54. * // Addresses are return synchronously
  55. * resolveAddress(addr, provider)
  56. * //_result:
  57. *
  58. * // Address promises are resolved asynchronously
  59. * resolveAddress(Promise.resolve(addr))
  60. * //_result:
  61. *
  62. * // ENS names are resolved asynchronously
  63. * resolveAddress("dai.tokens.ethers.eth", provider)
  64. * //_result:
  65. *
  66. * // Addressable objects are resolved asynchronously
  67. * contract = new Contract(addr, [ ])
  68. * resolveAddress(contract, provider)
  69. * //_result:
  70. *
  71. * // Unconfigured ENS names reject
  72. * resolveAddress("nothing-here.ricmoo.eth", provider)
  73. * //_error:
  74. *
  75. * // ENS names require a NameResolver object passed in
  76. * // (notice the provider was omitted)
  77. * resolveAddress("nothing-here.ricmoo.eth")
  78. * //_error:
  79. */
  80. export declare function resolveAddress(target: AddressLike, resolver?: null | NameResolver): string | Promise<string>;
  81. //# sourceMappingURL=checks.d.ts.map