From: Chris Duncan Date: Thu, 16 Oct 2025 02:43:06 +0000 (-0700) Subject: Deprecate multiple Account load signatures. X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=09822f8a3ed5940cb6be56e51b6aec9cee18bfec;p=libnemo.git Deprecate multiple Account load signatures. --- diff --git a/src/lib/account/index.ts b/src/lib/account/index.ts index 6b6d88a..4d90b65 100644 --- a/src/lib/account/index.ts +++ b/src/lib/account/index.ts @@ -172,20 +172,14 @@ export class Account { } /** - * Instantiates an Account object from its Nano address. + * Instantiates an Account object from its Nano address. It is unable to sign + * blocks or messages since it has no private key. * * @param {string} address - Address of the account * @returns {Account} A new Account object */ static load (address: string): Account /** - * Instantiates Account objects from their Nano addresses. - * - * @param {string[]} addresses - Addresses of the accounts - * @returns {Account[]} Array of new Account objects - */ - static load (addresses: string[]): Account[] - /** * Instantiates an Account object from its public key. It is unable to sign * blocks or messages since it has no private key. * @@ -194,14 +188,6 @@ export class Account { */ static load (publicKey: string | Uint8Array): Account /** - * Instantiates Account objects from their public keys. They are unable to sign - * blocks or messages since they have no private key. - * - * @param {string | Uint8Array[]} publicKeys - Public keys of the accounts - * @returns {Account[]} Array of new Account objects - */ - static load (publicKeys: string | Uint8Array[]): Account[] - /** * Instantiates an Account object from its public key. It is unable to sign * blocks or messages since it has no private key. * @@ -210,49 +196,20 @@ export class Account { */ static load (keypair: KeyPair): Account /** - * Instantiates Account objects from their public keys. They are unable to sign - * blocks or messages since they have no private key. - * - * @param {KeyPair[]} keypairs - Indexes and keys of the accounts - * @returns {Account[]} Array of new Account objects - */ - static load (keypairs: KeyPair[]): Account[] - /** * Instantiates an Account object from its private key which is used to derive * a public key and then discarded. * * @param {KeyPair} keypair - Index and key of the account * @param {string} type - Indicates a private key - * @returns {Promise} Promise for a new Account object - */ - static async load (keypair: KeyPair, type: 'private'): Promise - /** - * Instantiates Account objects from their private keys which are used to - * derive public keys and then discarded. - * - * @param {KeyPair[]} keypairs - Indexes and keys of the accounts - * @param {string} type - Indicates private keys - * @returns {Promise} Promise for array of new Account objects - */ - static async load (keypairs: KeyPair[], type: 'private'): Promise - /** - * Instantiates Account objects from their private keys which are used to - * derive public keys and then discarded. - * - * @param {(string | Uint8Array | KeyPair | (string | Uint8Array | KeyPair)[])} input - Indexes and keys of the accounts - * @param {'private'} [type] - Indicates private keys - * @returns {(Account | Account[] | Promise)} Promise for array of new Account objects + * @returns {Account} A new Account object */ - static load (input: string | Uint8Array | KeyPair | (string | Uint8Array | KeyPair)[], type?: 'private'): Account | Account[] | Promise { - const isInputArray = Array.isArray(input) - const inputs = isInputArray ? input : [input] + static load (keypair: KeyPair, type: 'private'): Account + static load (input: string | Uint8Array | KeyPair, type?: 'private'): Account { + const { address, publicKey, index } = _load(input, type) this.#isInternal = true - const accounts = inputs.map((input) => { - const { address, publicKey, index } = _load(input, type) - return new this(address, publicKey, index) - }) + const self = new this(address, publicKey, index) this.#isInternal = false - return isInputArray ? accounts : accounts[0] + return self } /**