Hey is a decentralized and permissionless social media app built with Lens Protocol 🌿

refactor: use strict types for collect button (#5906)

authored by yoginth.com and committed by

GitHub 4fa90c97 9360828b

+9 -5
+9 -5
apps/web/src/components/Post/OpenAction/CollectAction/CollectActionButton.tsx
··· 1 1 import { useApolloClient } from "@apollo/client"; 2 2 import { HEY_TREASURY } from "@hey/data/constants"; 3 3 import { 4 - type PostActionFragment, 5 4 type PostFragment, 5 + type SimpleCollectActionFragment, 6 6 useBalancesBulkQuery, 7 7 useExecutePostActionMutation 8 8 } from "@hey/indexer"; 9 9 import type { ApolloClientError } from "@hey/types/errors"; 10 10 import { useState } from "react"; 11 11 import { toast } from "sonner"; 12 + import type { Address } from "viem"; 12 13 import TopUpButton from "@/components/Shared/Account/TopUp/Button"; 13 14 import LoginButton from "@/components/Shared/LoginButton"; 14 15 import { Button, Spinner } from "@/components/Shared/UI"; ··· 20 21 interface CollectActionButtonProps { 21 22 collects: number; 22 23 onCollectSuccess?: () => void; 23 - postAction: PostActionFragment; 24 + postAction: SimpleCollectActionFragment; 24 25 post: PostFragment; 25 26 } 26 27 ··· 30 31 postAction, 31 32 post 32 33 }: CollectActionButtonProps) => { 33 - const collectAction = getCollectActionData(postAction as any); 34 + const collectAction = getCollectActionData(postAction); 34 35 const { currentAccount } = useAccountStore(); 35 36 const [isSubmitting, setIsSubmitting] = useState(false); 36 37 const [hasSimpleCollected, setHasSimpleCollected] = useState( ··· 42 43 const endTimestamp = collectAction?.endsAt; 43 44 const collectLimit = collectAction?.collectLimit; 44 45 const amount = collectAction?.price as number; 45 - const assetAddress = collectAction?.assetAddress as any; 46 + const assetAddress = collectAction?.assetAddress as Address | undefined; 46 47 const assetSymbol = collectAction?.assetSymbol as string; 47 48 const isAllCollected = collectLimit ? collects >= collectLimit : false; 48 49 const isSaleEnded = endTimestamp ··· 170 171 <TopUpButton 171 172 amountToTopUp={Math.ceil((amount - Number(tokenBalance)) * 20) / 20} 172 173 className="mt-5 w-full" 173 - token={{ contractAddress: assetAddress, symbol: assetSymbol }} 174 + token={{ 175 + contractAddress: assetAddress as Address, 176 + symbol: assetSymbol 177 + }} 174 178 /> 175 179 ); 176 180 }