From 036d15c448b17f8d6801f81938066cf5d7b5f748 Mon Sep 17 00:00:00 2001 From: Joel Carter Date: Mon, 23 Sep 2024 21:44:48 -0500 Subject: [PATCH] Add addressesContainsAddress helper --- .../src/lib/addresses/addressesContainsAddress.ts | 12 ++++++++++++ .../packages/validator/src/lib/addresses/index.ts | 1 + 2 files changed, 13 insertions(+) create mode 100644 packages/protocol/packages/boundwitness/packages/validator/src/lib/addresses/addressesContainsAddress.ts diff --git a/packages/protocol/packages/boundwitness/packages/validator/src/lib/addresses/addressesContainsAddress.ts b/packages/protocol/packages/boundwitness/packages/validator/src/lib/addresses/addressesContainsAddress.ts new file mode 100644 index 0000000000..033cd929c7 --- /dev/null +++ b/packages/protocol/packages/boundwitness/packages/validator/src/lib/addresses/addressesContainsAddress.ts @@ -0,0 +1,12 @@ +import type { Address } from '@xylabs/hex' +import type { BoundWitness } from '@xyo-network/boundwitness-model' + +/** + * Checks if the boundwitness contains the addresses + * @param bw The boundwitness to check + * @param addresses The address to check for + * @returns True if the boundwitness contains the addresses + */ +export const addressesContainsAddress = (bw: BoundWitness, address: Address): boolean => { + return bw.addresses?.includes(address) +} diff --git a/packages/protocol/packages/boundwitness/packages/validator/src/lib/addresses/index.ts b/packages/protocol/packages/boundwitness/packages/validator/src/lib/addresses/index.ts index 818d460193..270d5b9cd4 100644 --- a/packages/protocol/packages/boundwitness/packages/validator/src/lib/addresses/index.ts +++ b/packages/protocol/packages/boundwitness/packages/validator/src/lib/addresses/index.ts @@ -1,2 +1,3 @@ +export * from './addressesContainsAddress.ts' export * from './addressesContainsAll.ts' export * from './addressesContainsAny.ts'