Hey is a decentralized and permissionless social media app built with Lens Protocol 馃尶
1import type {
2 RecipientPercent,
3 SimpleCollectActionFragment
4} from "@hey/indexer";
5
6interface CollectActionData {
7 price?: number;
8 assetAddress?: string;
9 assetSymbol?: string;
10 collectLimit?: number;
11 endsAt?: string;
12 recipients?: RecipientPercent[];
13}
14
15const getCollectActionData = (
16 collectAction: SimpleCollectActionFragment
17): CollectActionData | null => {
18 if (collectAction.__typename !== "SimpleCollectAction") {
19 return null;
20 }
21
22 const { payToCollect, collectLimit, endsAt } = collectAction;
23
24 return {
25 assetAddress: payToCollect?.price?.asset?.contract?.address,
26 assetSymbol: payToCollect?.price?.asset?.symbol,
27 collectLimit: Number(collectLimit),
28 endsAt,
29 price: Number.parseFloat(payToCollect?.price?.value ?? "0"),
30 recipients: payToCollect?.recipients ?? []
31 };
32};
33
34export default getCollectActionData;