* @returns {Promise<Account[]>} Promise for array of new Account objects\r
*/\r
static async import (keypairs: KeyPair[], password: Key): Promise<Account[]>\r
- static import (input: Key | Key[] | KeyPair | KeyPair[], password?: Key): Account | Account[] | Promise<Account | Account[]> {\r
- if (Array.isArray(input)) {\r
- if (this.#isKeyPairs(input) && password != null) {\r
- return new Promise((resolve, reject): void => {\r
- this.#fromPrivate(input, password)\r
- .then(r => resolve(r))\r
- .catch(e => reject(e))\r
- })\r
- }\r
- return this.#fromPublic(input)\r
+ static import (input: Key | KeyPair | (Key | KeyPair)[], password?: Key): Account | Account[] | Promise<Account | Account[]> {\r
+ const isInputArray = Array.isArray(input)\r
+ const inputs = isInputArray ? input : [input]\r
+ if (this.#isKeyPairs(inputs) && password != null) {\r
+ return new Promise((resolve, reject): void => {\r
+ this.#fromPrivate(inputs, password)\r
+ .then(r => resolve(isInputArray ? r : r[0]))\r
+ .catch(e => reject(e))\r
+ })\r
} else {\r
- const inputs = [input]\r
- if (this.#isKeyPairs(inputs) && password != null) {\r
- return new Promise((resolve, reject): void => {\r
- this.#fromPrivate(inputs, password)\r
- .then(r => resolve(r[0]))\r
- .catch(e => reject(e))\r
- })\r
- }\r
- return this.#fromPublic(inputs)[0]\r
+ return isInputArray ? this.#fromPublic(inputs) : this.#fromPublic(inputs)[0]\r
}\r
}\r
\r