From 96c5573da1e5b0e70f08439bf221418fea2606a5 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Thu, 17 Jul 2025 08:37:22 -0700 Subject: [PATCH] Mark restricted constructors as private to inform Typescript engine. --- src/lib/account.ts | 2 +- src/lib/bip39-mnemonic.ts | 2 +- src/lib/entropy.ts | 2 +- src/lib/wallets/bip44-wallet.ts | 2 +- src/lib/wallets/blake2b-wallet.ts | 2 +- src/lib/wallets/ledger-wallet.ts | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib/account.ts b/src/lib/account.ts index 6fa9f44..9d571cc 100644 --- a/src/lib/account.ts +++ b/src/lib/account.ts @@ -50,7 +50,7 @@ export class Account { } set weight (v) { this.#weight = v ? BigInt(v) : undefined } - constructor (address: string, publicKey: Uint8Array) { + private constructor (address: string, publicKey: Uint8Array) { if (!Account.#isInternal) { throw new Error(`Account cannot be instantiated directly. Use factory methods instead.`) } diff --git a/src/lib/bip39-mnemonic.ts b/src/lib/bip39-mnemonic.ts index c1d7cfe..e286d76 100644 --- a/src/lib/bip39-mnemonic.ts +++ b/src/lib/bip39-mnemonic.ts @@ -18,7 +18,7 @@ export class Bip39Mnemonic { #phrase: string = '' get phrase (): string { return this.#phrase.normalize('NFKD') } - constructor () { + private constructor () { if (!Bip39Mnemonic.#isInternal) { throw new Error(`Bip39Mnemonic must be created with async methods 'fromPhrase()' or 'fromEntropy().`) } diff --git a/src/lib/entropy.ts b/src/lib/entropy.ts index f3563a6..ccacb06 100644 --- a/src/lib/entropy.ts +++ b/src/lib/entropy.ts @@ -24,7 +24,7 @@ export class Entropy { get bytes (): Uint8Array { return this.#bytes } get hex (): string { return bytes.toHex(this.#bytes) } - constructor (bytes: Uint8Array) { + private constructor (bytes: Uint8Array) { if (!Entropy.#isInternal) { throw new Error(`Entropy cannot be instantiated directly. Use 'await Entropy.create()' instead.`) } diff --git a/src/lib/wallets/bip44-wallet.ts b/src/lib/wallets/bip44-wallet.ts index bd1ca66..79c18cd 100644 --- a/src/lib/wallets/bip44-wallet.ts +++ b/src/lib/wallets/bip44-wallet.ts @@ -34,7 +34,7 @@ import { Bip44CkdWorker } from '#workers' export class Bip44Wallet extends Wallet { static #isInternal: boolean = false - constructor (id: Entropy, seed?: Uint8Array, mnemonic?: Bip39Mnemonic) { + private constructor (id: Entropy, seed?: Uint8Array, mnemonic?: Bip39Mnemonic) { if (!Bip44Wallet.#isInternal) { throw new Error(`Bip44Wallet cannot be instantiated directly. Use 'await Bip44Wallet.create()' instead.`) } diff --git a/src/lib/wallets/blake2b-wallet.ts b/src/lib/wallets/blake2b-wallet.ts index 505e418..e093069 100644 --- a/src/lib/wallets/blake2b-wallet.ts +++ b/src/lib/wallets/blake2b-wallet.ts @@ -28,7 +28,7 @@ import { KeyPair } from '#types' export class Blake2bWallet extends Wallet { static #isInternal: boolean = false - constructor (id: Entropy, seed?: Uint8Array, mnemonic?: Bip39Mnemonic) { + private constructor (id: Entropy, seed?: Uint8Array, mnemonic?: Bip39Mnemonic) { if (!Blake2bWallet.#isInternal) { throw new Error(`Blake2bWallet cannot be instantiated directly. Use 'await Blake2bWallet.create()' instead.`) } diff --git a/src/lib/wallets/ledger-wallet.ts b/src/lib/wallets/ledger-wallet.ts index ec9cf03..ca7175f 100644 --- a/src/lib/wallets/ledger-wallet.ts +++ b/src/lib/wallets/ledger-wallet.ts @@ -61,7 +61,7 @@ export class LedgerWallet extends Wallet { DynamicTransport: typeof TransportBLE | typeof TransportUSB | typeof TransportHID = TransportHID - constructor (id: Entropy) { + private constructor (id: Entropy) { if (!LedgerWallet.#isInternal) { throw new Error(`LedgerWallet cannot be instantiated directly. Use 'await LedgerWallet.create()' instead.`) } -- 2.47.3