forked from myBraavos/starknet-meta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
24 lines (19 loc) · 827 Bytes
/
index.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
import type { Category, Contract, Project } from "./types";
import { contractsMap, projectsMap } from "./parser";
import { normalizeAddress } from "./utils";
import { formatError } from "./errors";
export const list = (): Project[] => Object.values(projectsMap);
export const get = (id: string): Project | undefined => projectsMap[id];
export const getProjectByContractAddress = (
address: string
): Project | undefined => contractsMap[normalizeAddress(address)]?.project;
export const getContractByAddress = (
address: string
): { contract: Contract; project: Project } | undefined => {
const { contract, project } = contractsMap[normalizeAddress(address)] ?? {};
if (!contract || !project) {
return undefined;
}
return { contract, project };
};
export { formatError, Category, Project };