address.d.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * Returns a normalized and checksumed address for %%address%%.
  3. * This accepts non-checksum addresses, checksum addresses and
  4. * [[getIcapAddress]] formats.
  5. *
  6. * The checksum in Ethereum uses the capitalization (upper-case
  7. * vs lower-case) of the characters within an address to encode
  8. * its checksum, which offers, on average, a checksum of 15-bits.
  9. *
  10. * If %%address%% contains both upper-case and lower-case, it is
  11. * assumed to already be a checksum address and its checksum is
  12. * validated, and if the address fails its expected checksum an
  13. * error is thrown.
  14. *
  15. * If you wish the checksum of %%address%% to be ignore, it should
  16. * be converted to lower-case (i.e. ``.toLowercase()``) before
  17. * being passed in. This should be a very rare situation though,
  18. * that you wish to bypass the safegaurds in place to protect
  19. * against an address that has been incorrectly copied from another
  20. * source.
  21. *
  22. * @example:
  23. * // Adds the checksum (via upper-casing specific letters)
  24. * getAddress("0x8ba1f109551bd432803012645ac136ddd64dba72")
  25. * //_result:
  26. *
  27. * // Converts ICAP address and adds checksum
  28. * getAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36");
  29. * //_result:
  30. *
  31. * // Throws an error if an address contains mixed case,
  32. * // but the checksum fails
  33. * getAddress("0x8Ba1f109551bD432803012645Ac136ddd64DBA72")
  34. * //_error:
  35. */
  36. export declare function getAddress(address: string): string;
  37. /**
  38. * The [ICAP Address format](link-icap) format is an early checksum
  39. * format which attempts to be compatible with the banking
  40. * industry [IBAN format](link-wiki-iban) for bank accounts.
  41. *
  42. * It is no longer common or a recommended format.
  43. *
  44. * @example:
  45. * getIcapAddress("0x8ba1f109551bd432803012645ac136ddd64dba72");
  46. * //_result:
  47. *
  48. * getIcapAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36");
  49. * //_result:
  50. *
  51. * // Throws an error if the ICAP checksum is wrong
  52. * getIcapAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK37");
  53. * //_error:
  54. */
  55. export declare function getIcapAddress(address: string): string;
  56. //# sourceMappingURL=address.d.ts.map