]> git.codecow.com Git - libnemo.git/commitdiff
Update static member access and fix type definition for Rolodex.
authorChris Duncan <chris@zoso.dev>
Mon, 11 Aug 2025 16:03:02 +0000 (09:03 -0700)
committerChris Duncan <chris@zoso.dev>
Mon, 11 Aug 2025 16:03:02 +0000 (09:03 -0700)
src/lib/rolodex.ts
src/types.d.ts

index 28809de0a78b6ce185f574b85583edc9fbae41a9..d9fd003faa90367028e3d82218b56294ae9abbd1 100644 (file)
@@ -72,7 +72,7 @@ export class Rolodex {
                                id: name,
                                addresses
                        }
-                       const results = await Database.put(data, this.#DB_NAME)
+                       const results = await Database.put(data, Rolodex.#DB_NAME)
                        if (results.length !== Object.keys(data).length) {
                                throw new Error('Unexpected results from adding address', { cause: results })
                        }
@@ -100,11 +100,11 @@ export class Rolodex {
                                addresses
                        }
                }
-               const isUpdated = await Database.put(data, this.#DB_NAME)
+               const isUpdated = await Database.put(data, Rolodex.#DB_NAME)
                if (!isUpdated) {
                        throw new Error('failed to remove address from existing name')
                }
-               const isDeleted = await Database.delete(address, this.#DB_NAME)
+               const isDeleted = await Database.delete(address, Rolodex.#DB_NAME)
                return isDeleted
        }
 
@@ -117,7 +117,7 @@ export class Rolodex {
        static async deleteName (name: string): Promise<boolean> {
                const records = await this.getAddresses(name)
                records.push(name)
-               return await Database.delete(records, this.#DB_NAME)
+               return await Database.delete(records, Rolodex.#DB_NAME)
        }
 
        /**
@@ -128,7 +128,7 @@ export class Rolodex {
        */
        static async getAddresses (name: string): Promise<string[]> {
                try {
-                       const records = await Database.get<NamedData<string[]>>(name, this.#DB_NAME)
+                       const records = await Database.get<NamedData<string[]>>(name, Rolodex.#DB_NAME)
                        const record = records[name]
                        return record?.addresses
                                ? record.addresses.sort()
@@ -146,7 +146,7 @@ export class Rolodex {
        */
        static async getAllNames (): Promise<string[]> {
                try {
-                       const records = await Database.getAll<NamedData>(this.#DB_NAME)
+                       const records = await Database.getAll<NamedData>(Rolodex.#DB_NAME)
                        return Object.keys(records).filter(v => v.slice(0, 5) !== 'nano_')
                } catch (err) {
                        console.error(err)
@@ -162,7 +162,7 @@ export class Rolodex {
        */
        static async getName (address: string): Promise<string | null> {
                try {
-                       const records = await Database.get<NamedData<string>>(address, this.#DB_NAME)
+                       const records = await Database.get<NamedData<string>>(address, Rolodex.#DB_NAME)
                        const record = records[address]
                        return record?.name ?? null
                } catch (err) {
index 6ac21e56802c2bcc3960dd0f5a7e500c3c1c6d54..e5916dd9eda456a6e98b74fb8e26489a5622818f 100644 (file)
@@ -376,7 +376,7 @@ export type KeyPair = {
 * saved under one nickname.
 */
 export declare class Rolodex {
-       #private
+       static #private
        /**
        * Adds an address to the rolodex under a specific nickname.
        *