From 4798b15769a50c606fb98297ccd3b1ea62e3757a Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Thu, 24 Jul 2025 08:04:43 -0700 Subject: [PATCH] Update types. --- src/main.ts | 10 +++++++- src/types.d.ts | 67 ++++++++++++++++++++++++-------------------------- 2 files changed, 41 insertions(+), 36 deletions(-) diff --git a/src/main.ts b/src/main.ts index fe7b46f..7d4fb46 100644 --- a/src/main.ts +++ b/src/main.ts @@ -9,4 +9,12 @@ import { Rpc } from './lib/rpc' import { Tools } from './lib/tools' import { Bip44Wallet, Blake2bWallet, LedgerWallet } from './lib/wallets' -export { Account, Blake2b, ChangeBlock, ReceiveBlock, SendBlock, Rolodex, Rpc, Tools, Bip44Wallet, Blake2bWallet, LedgerWallet } +export { + Account, + Blake2b, + ChangeBlock, ReceiveBlock, SendBlock, + Rolodex, + Rpc, + Tools, + Bip44Wallet, Blake2bWallet, LedgerWallet +} diff --git a/src/types.d.ts b/src/types.d.ts index adc548e..9670864 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -12,6 +12,7 @@ import { default as TransportHID } from '@ledgerhq/hw-transport-webhid' * be fetched from the network. */ export declare class Account { + #private get address (): string get index (): number | undefined get publicKey (): string @@ -34,7 +35,7 @@ export declare class Account { /** * Instantiates an Account object from its Nano address. * - * @param {string} addresses - Address of the account + * @param {string} address - Address of the account * @returns {Account} A new Account object */ static import (address: string): Account @@ -148,6 +149,7 @@ export declare class Account { */ static validate (address: unknown): asserts address is string } + export declare class AccountList extends Object { [index: number]: Account get length (): number; @@ -190,6 +192,11 @@ export declare class Bip39Mnemonic { */ static checksum (entropy: Entropy): Promise /** + * Erases seed bytes and releases variable references to allow garbage + * collection. + */ + destroy (): void + /** * Validates a mnemonic phrase. * * @param {string} mnemonic - Mnemonic phrase to validate @@ -297,12 +304,8 @@ declare abstract class Block { */ process (rpc: Rpc): Promise /** - * Signs the block using a private key. If a key is not provided, the private - * key of the block's account will be used if it exists. If that fails, an - * error is thrown. - * - * If successful, the result is stored in the object's `signature` - * property. + * Signs the block using a private key. If successful, the result is stored in + * the object's `signature` property. * * @param {string} [key] - Hexadecimal-formatted private key to use for signing */ @@ -502,6 +505,28 @@ export declare class Rolodex { static verify (name: string, signature: string, ...data: string[]): Promise } +/** +* Represents a Nano network node. It primarily consists of a URL which will +* accept RPC calls, and an optional API key header construction can be passed if +* required by the node. Once instantiated, the Rpc object can be used to call +* any action supported by the Nano protocol. The URL protocol must be HTTPS; any +* other value will be changed automatically. +*/ +export declare class Rpc { + #private + constructor (url: string | URL, apiKeyName?: string) + /** + * Sends a nano RPC call to a node endpoint. + * + * @param {string} action - Nano protocol RPC call to execute + * @param {object} [data] - JSON to send to the node as defined by the action + * @returns {Promise} JSON-formatted RPC results from the node + */ + call (action: string, data?: { + [key: string]: unknown + }): Promise +} + type SweepResult = { status: "success" | "error" address: string @@ -545,7 +570,6 @@ export declare function sweep (rpc: Rpc | string | URL, wallet: Blake2bWallet | * @returns {Promise} True if the data was signed by the public key's matching private key */ export declare function verify (key: Key, signature: string, ...input: string[]): Promise - export declare const Tools: { convert: typeof convert hash: typeof hash @@ -1016,33 +1040,6 @@ export declare const Bip44CkdWorker: WorkerQueue export declare const NanoNaClWorker: WorkerQueue export declare const SafeWorker: WorkerQueue -/** -* Represents a Nano network node. It primarily consists of a URL which will -* accept RPC calls, and an optional API key header construction can be passed if -* required by the node. Once instantiated, the Rpc object can be used to call -* any action supported by the Nano protocol. The URL protocol must be HTTPS; any -* other value will be changed automatically. -*/ -export declare class Rpc { - constructor (url: string | URL, apiKeyName?: string) - /** - * - * @param {string} action - Nano protocol RPC call to execute - * @param {object} [data] - JSON to send to the node as defined by the action - * @returns {Promise} JSON-formatted RPC results from the node - */ - call (action: string, data?: { - [key: string]: any - }): Promise -} - -export type SafeRecord = { - label: string - iv: ArrayBuffer - salt: ArrayBuffer - encrypted: ArrayBuffer -} - export type UnknownNumber = number | unknown export type UnknownUint8Array = Uint8Array | unknown -- 2.47.3