From 6c5d8eb594f9db58666b38af866c5e760d50ecec Mon Sep 17 00:00:00 2001 From: git Date: Tue, 14 Dec 2021 11:47:57 -0500 Subject: [PATCH] propsed adding a constant for supported protocols and a helper function that returns a boolean if it is found or not --- app/src/utils/utils.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/utils/utils.ts b/app/src/utils/utils.ts index d35bde5a..16d07463 100644 --- a/app/src/utils/utils.ts +++ b/app/src/utils/utils.ts @@ -481,10 +481,14 @@ Promise => { } }; +const supportedProtocols = ['1']; +const isSupportedProtocol = (protocol: string) => supportedProtocols.includes(protocol); + export function assertIPFSPointer(logoPtr: MetaPtr | undefined) { if (!logoPtr) throw new Error('assertIPFSPointer: logoPtr is undefined'); const protocol = BigNumber.from(logoPtr.protocol).toString(); - if (!['0', '1'].includes(protocol)) + + if (!isSupportedProtocol(protocol)) throw new Error(`assertIPFSPointer: Expected protocol ID of 0 or 1, found ${protocol}`); }