Skip to content

Commit

Permalink
propsed adding a constant for supported protocols and a helper functi…
Browse files Browse the repository at this point in the history
…on that returns a boolean if it is found or not
  • Loading branch information
jjwoz committed Dec 14, 2021
1 parent 5b4409d commit 6c5d8eb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,10 +481,14 @@ Promise<any[]> => {
}
};

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}`);
}

Expand Down

0 comments on commit 6c5d8eb

Please sign in to comment.