* @returns {Promise<Account[]>} Promise for array of new Account objects\r
*/\r
static async load (keypairs: KeyPair[], type: 'private'): Promise<Account[]>\r
+ /**\r
+ * Instantiates Account objects from their private keys which are used to\r
+ * derive public keys and then discarded.\r
+ *\r
+ * @param {string | Uint8Array<ArrayBuffer> | KeyPair | (string | Uint8Array<ArrayBuffer> | KeyPair)[]} input - Indexes and keys of the accounts\r
+ * @param {'private'} [type] - Indicates private keys\r
+ * @returns {Account | Account[] | Promise<Account | Account[]>} Promise for array of new Account objects\r
+ */\r
static load (input: string | Uint8Array<ArrayBuffer> | KeyPair | (string | Uint8Array<ArrayBuffer> | KeyPair)[], type?: 'private'): Account | Account[] | Promise<Account | Account[]> {\r
const isInputArray = Array.isArray(input)\r
const inputs = isInputArray ? input : [input]\r
if (this.#isKeyPairs(inputs) && type === 'private') {\r
- return new Promise((resolve, reject): void => {\r
- this.#fromPrivate(inputs)\r
- .then(r => resolve(isInputArray ? r : r[0]))\r
- .catch(e => reject(e))\r
- })\r
+ return this.#fromPrivate(inputs)\r
+ .then(r => isInputArray ? r : r[0])\r
} else {\r
return isInputArray ? this.#fromPublic(inputs) : this.#fromPublic(inputs)[0]\r
}\r
* the corresponding public key and then discarded.\r
*\r
* @param {KeyPair} keypairs - Indexes and keys of the accounts\r
- * @returns {Account} A new Account object\r
+ * @returns {Promise<Account[]>} Promise for new Account objects\r
*/\r
static async #fromPrivate (keypairs: KeyPair[]): Promise<Account[]> {\r
try {\r
#u: URL
#n?: string
+ /**
+ * @param {(string|URL)} url
+ * @param {string} [apiKeyName]
+ */
constructor (url: string | URL, apiKeyName?: string) {
this.#u = new URL(url)
this.#u.protocol = 'https:'
throw new TypeError('Wallet secret must be a string', { cause: typeof secret })
}
if (type === 'Ledger') {
- const { Ledger } = await import('../ledger')
return await Ledger.verify(secret)
} else {
const data: { [key: string]: string | ArrayBuffer } = {
*/
let Wallet
-if (isNode) {
- ({ Account, Block, Ledger, Rpc, Wallet } = await import('../dist/nodejs.min.js'))
-} else {
- ({ Account, Block, Ledger, Rpc, Wallet } = await import('../dist/browser.min.js'))
-}
+{ ({ Account, Block, Ledger, Rpc, Wallet } = await import('libnemo')) }
const rpc = new Rpc(env.NODE_URL ?? '', env.API_KEY_NAME)