Skip to content

Commit

Permalink
feat: modify function name
Browse files Browse the repository at this point in the history
  • Loading branch information
Polybius93 committed Jul 12, 2024
1 parent 930fd17 commit ce9eb2a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
7 changes: 3 additions & 4 deletions src/functions/proof-of-reserve/proof-of-reserve-functions.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -21,10 +21,9 @@ export async function verifyVaultDeposit(
bitcoinNetwork: Network
): Promise<number> {
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);

Expand Down
2 changes: 1 addition & 1 deletion src/utilities/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function isDefined<T>(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 !== '';
}

Expand Down
10 changes: 5 additions & 5 deletions tests/unit/utility.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
customShiftValue,
delay,
isDefined,
isStringDefinedAndNotEmpty,
isNonEmptyString,
isUndefined,
reverseBytes,
shiftValue,
Expand Down Expand Up @@ -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);
});
});
Expand Down

0 comments on commit ce9eb2a

Please sign in to comment.