import { IReadWriteWallet, IWalletData, IWalletExportOptions } from "./contracts"; /** * Defines the implementation contract for the wallet repository. * * @export * @interface IWalletRepository */ export interface IWalletRepository { /** * Get all keys and values. * * @returns {Record} * @memberof IWalletRepository */ all(): Record; /** * Get the first wallet. * * @returns {IReadWriteWallet} * @memberof IWalletRepository */ first(): IReadWriteWallet; /** * Get the last wallet. * * @returns {IReadWriteWallet} * @memberof IWalletRepository */ last(): IReadWriteWallet; /** * Get all wallets grouped by their coin and network. * * @returns {Record>} * @memberof IWalletRepository */ allByCoin(): Record>; /** * Get all keys. * * @returns {string[]} * @memberof IWalletRepository */ keys(): string[]; /** * Get all values. * * @returns {IReadWriteWallet[]} * @memberof IWalletRepository */ values(): IReadWriteWallet[]; /** * Fill the storage with wallet data. * * @param {Record} struct * @returns {Promise} * @memberof IWalletRepository */ fill(struct: Record): Promise; /** * Restore the wallets. * * @returns {Promise} * @memberof IWalletRepository */ restore(): Promise; /** * Find a wallet by its ID. * * @param {string} id * @returns {IReadWriteWallet} * @memberof IWalletRepository */ findById(id: string): IReadWriteWallet; /** * Find a wallet by its address. * * @param {string} address * @returns {(IReadWriteWallet | undefined)} * @memberof IWalletRepository */ findByAddress(address: string): IReadWriteWallet | undefined; /** * Find a wallet by its public key. * * @param {string} publicKey * @returns {(IReadWriteWallet | undefined)} * @memberof IWalletRepository */ findByPublicKey(publicKey: string): IReadWriteWallet | undefined; /** * Find many wallets by their coins. * * @param {string} coin * @returns {IReadWriteWallet[]} * @memberof IWalletRepository */ findByCoin(coin: string): IReadWriteWallet[]; /** * Find many wallets by their coin and network. * * @param {string} coin * @param {string} network * @returns {IReadWriteWallet[]} * @memberof IWalletRepository */ findByCoinWithNetwork(coin: string, network: string): IReadWriteWallet[]; /** * Find a wallet by its alias. * * @param {string} alias * @returns {(IReadWriteWallet | undefined)} * @memberof IWalletRepository */ findByAlias(alias: string): IReadWriteWallet | undefined; /** * Store a new wallet instance using its unique ID. * * @private * @param {IReadWriteWallet} wallet * @param {{ force: boolean }} [options={ force: false }] * @returns {IReadWriteWallet} * @memberof WalletRepository */ push(wallet: IReadWriteWallet, options?: { force: boolean; }): IReadWriteWallet; /** * Update a wallet. * * @param {string} id * @param {{ alias?: string }} data * @memberof IWalletRepository */ update(id: string, data: { alias?: string; }): void; /** * Determine if the wallet exists. * * @param {string} id * @returns {boolean} * @memberof IWalletRepository */ has(id: string): boolean; /** * Remove the wallet for the given ID. * * @param {string} id * @memberof IWalletRepository */ forget(id: string): void; /** * Remove all wallets. * * @memberof IWalletRepository */ flush(): void; /** * Count how many wallets there are. * * @returns {number} * @memberof IWalletRepository */ count(): number; /** * Turn the wallets into a normalised object. * * @param {IWalletExportOptions} options * @returns {Record} * @memberof IWalletRepository */ toObject(options: IWalletExportOptions): Record; /** * Get all wallets sorted by the given column. * * @param {string} column * @param {("asc" | "desc")} direction * @returns {IReadWriteWallet[]} * @memberof IWalletRepository */ sortBy(column: string, direction: "asc" | "desc"): IReadWriteWallet[]; }