diff --git a/src/functions/proof-of-reserve/proof-of-reserve-functions.ts b/src/functions/proof-of-reserve/proof-of-reserve-functions.ts index 0aa1b6c..b155189 100644 --- a/src/functions/proof-of-reserve/proof-of-reserve-functions.ts +++ b/src/functions/proof-of-reserve/proof-of-reserve-functions.ts @@ -1,7 +1,7 @@ import { Network } from 'bitcoinjs-lib'; import { RawVault } from '../../models/ethereum-models.js'; -import { isStringDefinedAndNotEmpty } from '../../utilities/index.js'; +import { isNonEmptyString } from '../../utilities/index.js'; import { createTaprootMultisigPayment, deriveUnhardenedPublicKey, @@ -21,10 +21,9 @@ export async function verifyVaultDeposit( bitcoinNetwork: Network ): Promise { try { - if (!isStringDefinedAndNotEmpty(vault.wdTxId) && !isStringDefinedAndNotEmpty(vault.fundingTxId)) - return 0; + if (!isNonEmptyString(vault.wdTxId) && !isNonEmptyString(vault.fundingTxId)) return 0; - const txID = isStringDefinedAndNotEmpty(vault.wdTxId) ? vault.wdTxId : vault.fundingTxId; + const txID = isNonEmptyString(vault.wdTxId) ? vault.wdTxId : vault.fundingTxId; const fundingTransaction = await fetchBitcoinTransaction(txID, bitcoinBlockchainAPI); diff --git a/src/utilities/index.ts b/src/utilities/index.ts index a2aa465..babfb8f 100644 --- a/src/utilities/index.ts +++ b/src/utilities/index.ts @@ -45,7 +45,7 @@ export function isDefined(argument: T | undefined): argument is T { return !isUndefined(argument); } -export function isStringDefinedAndNotEmpty(string: string | undefined): boolean { +export function isNonEmptyString(string: string | undefined): boolean { return isDefined(string) && string !== ''; } diff --git a/tests/unit/utility.test.ts b/tests/unit/utility.test.ts index 0a66af7..9677c9b 100644 --- a/tests/unit/utility.test.ts +++ b/tests/unit/utility.test.ts @@ -4,7 +4,7 @@ import { customShiftValue, delay, isDefined, - isStringDefinedAndNotEmpty, + isNonEmptyString, isUndefined, reverseBytes, shiftValue, @@ -89,22 +89,22 @@ describe('Utility Functions', () => { }); }); - describe('isStringDefinedAndNotEmpty', () => { + describe('isNonEmptyString', () => { it('correctly identifies if a string is defined and not empty', () => { const value = 'Hello, World!'; - const isValueDefinedAndNotEmpty = isStringDefinedAndNotEmpty(value); + const isValueDefinedAndNotEmpty = isNonEmptyString(value); expect(isValueDefinedAndNotEmpty).toBe(true); }); it('correctly identifies if a string is not defined', () => { const value = undefined; - const isValueDefinedAndNotEmpty = isStringDefinedAndNotEmpty(value); + const isValueDefinedAndNotEmpty = isNonEmptyString(value); expect(isValueDefinedAndNotEmpty).toBe(false); }); it('correctly identifies if a string is defined but empty', () => { const value = ''; - const isValueDefinedAndNotEmpty = isStringDefinedAndNotEmpty(value); + const isValueDefinedAndNotEmpty = isNonEmptyString(value); expect(isValueDefinedAndNotEmpty).toBe(false); }); });