-
Notifications
You must be signed in to change notification settings - Fork 4
/
isAssetMetadata.ts
28 lines (27 loc) · 1002 Bytes
/
isAssetMetadata.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { LSP4DigitalAssetMetadataJSON } from '@lukso/lsp-smart-contracts';
/**
* Returns `true` is the passed object is an LSP4 Asset Metadata, `false` otherwise.
*
* @since v0.0.1
* @category LSP4
* @param object - The object that is to be checked.
* @see https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-3-Profile-Metadata.md
* @example
* ```ts
* isAssetMetadata({ LSP4Metadata: { description: "", links: [], images: [], assets: [] icon: [] } }) => true
* isAssetMetadata({ description: "", links: [], name: "", tags: [] }) => false
* ```
*/
export const isAssetMetadata = (
// eslint-disable-next-line @typescript-eslint/no-explicit-any
object: any,
): object is LSP4DigitalAssetMetadataJSON => {
return (
'LSP4Metadata' in object &&
'description' in object.LSP4Metadata &&
'links' in object.LSP4Metadata &&
'images' in object.LSP4Metadata &&
'assets' in object.LSP4Metadata &&
'icon' in object.LSP4Metadata
);
};