]> git.codecow.com Git - libnemo.git/commitdiff
Import bare specifier in test.
authorChris Duncan <chris@zoso.dev>
Mon, 22 Sep 2025 05:10:49 +0000 (22:10 -0700)
committerChris Duncan <chris@zoso.dev>
Mon, 22 Sep 2025 05:10:49 +0000 (22:10 -0700)
src/lib/account/index.ts
src/lib/rpc.ts
src/lib/wallet/verify.ts
test/test.ledger.mjs

index 850307bd863f9b17985ba725884a69177d960ab7..5019cac36c5dd9260187619a4de934c9bb08bcdd 100644 (file)
@@ -236,15 +236,20 @@ export class Account {
        * @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
@@ -278,7 +283,7 @@ export class Account {
        * 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
index 885f42ff29e559b22890c547df89fff5a69a44ac..9b361e2d132698a571ca175ad16820f3ec2076a1 100644 (file)
@@ -12,6 +12,10 @@ export class Rpc {
        #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:'
index 86bf4b8218b0d0285611e4b5ce143434fae48a3d..f364e7a80c067bba813178b039b9df6723296c6b 100644 (file)
@@ -13,7 +13,6 @@ export async function _verify (type: WalletType, vault: Vault, secret: unknown):
                        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 } = {
index 30128a147a66035a3234626372c8a44795c2228d..aae1bf0b20bb45dcf12b65f165c32e6b6b3c5c25 100644 (file)
@@ -27,11 +27,7 @@ let Rpc
 */
 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)