wallet.d.ts 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import { SigningKey } from "../crypto/index.js";
  2. import { BaseWallet } from "./base-wallet.js";
  3. import { HDNodeWallet } from "./hdwallet.js";
  4. import type { ProgressCallback } from "../crypto/index.js";
  5. import type { Provider } from "../providers/index.js";
  6. /**
  7. * A **Wallet** manages a single private key which is used to sign
  8. * transactions, messages and other common payloads.
  9. *
  10. * This class is generally the main entry point for developers
  11. * that wish to use a private key directly, as it can create
  12. * instances from a large variety of common sources, including
  13. * raw private key, [[link-bip-39]] mnemonics and encrypte JSON
  14. * wallets.
  15. */
  16. export declare class Wallet extends BaseWallet {
  17. #private;
  18. /**
  19. * Create a new wallet for the private %%key%%, optionally connected
  20. * to %%provider%%.
  21. */
  22. constructor(key: string | SigningKey, provider?: null | Provider);
  23. connect(provider: null | Provider): Wallet;
  24. /**
  25. * Resolves to a [JSON Keystore Wallet](json-wallets) encrypted with
  26. * %%password%%.
  27. *
  28. * If %%progressCallback%% is specified, it will receive periodic
  29. * updates as the encryption process progreses.
  30. */
  31. encrypt(password: Uint8Array | string, progressCallback?: ProgressCallback): Promise<string>;
  32. /**
  33. * Returns a [JSON Keystore Wallet](json-wallets) encryped with
  34. * %%password%%.
  35. *
  36. * It is preferred to use the [async version](encrypt) instead,
  37. * which allows a [[ProgressCallback]] to keep the user informed.
  38. *
  39. * This method will block the event loop (freezing all UI) until
  40. * it is complete, which may be a non-trivial duration.
  41. */
  42. encryptSync(password: Uint8Array | string): string;
  43. /**
  44. * Creates (asynchronously) a **Wallet** by decrypting the %%json%%
  45. * with %%password%%.
  46. *
  47. * If %%progress%% is provided, it is called periodically during
  48. * decryption so that any UI can be updated.
  49. */
  50. static fromEncryptedJson(json: string, password: Uint8Array | string, progress?: ProgressCallback): Promise<HDNodeWallet | Wallet>;
  51. /**
  52. * Creates a **Wallet** by decrypting the %%json%% with %%password%%.
  53. *
  54. * The [[fromEncryptedJson]] method is preferred, as this method
  55. * will lock up and freeze the UI during decryption, which may take
  56. * some time.
  57. */
  58. static fromEncryptedJsonSync(json: string, password: Uint8Array | string): HDNodeWallet | Wallet;
  59. /**
  60. * Creates a new random [[HDNodeWallet]] using the available
  61. * [cryptographic random source](randomBytes).
  62. *
  63. * If there is no crytographic random source, this will throw.
  64. */
  65. static createRandom(provider?: null | Provider): HDNodeWallet;
  66. /**
  67. * Creates a [[HDNodeWallet]] for %%phrase%%.
  68. */
  69. static fromPhrase(phrase: string, provider?: Provider): HDNodeWallet;
  70. }
  71. //# sourceMappingURL=wallet.d.ts.map