diff --git a/package.json b/package.json index 2196fa7..854e5b5 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "@radix-ui/react-accordion": "^1.2.2", "@radix-ui/react-dialog": "^1.1.4", "@radix-ui/react-popover": "^1.1.4", + "@radix-ui/react-select": "^2.1.4", "@radix-ui/react-slot": "^1.1.1", "@radix-ui/react-tooltip": "^1.1.6", "@solana/spl-token": "^0.4.9", diff --git a/public/icons/currencies/usdcMint.svg b/public/icons/currencies/usdcMint.svg new file mode 100644 index 0000000..10cdb67 --- /dev/null +++ b/public/icons/currencies/usdcMint.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/public/icons/currencies/usdtMint.svg b/public/icons/currencies/usdtMint.svg new file mode 100644 index 0000000..328392a --- /dev/null +++ b/public/icons/currencies/usdtMint.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/public/icons/currencies/wSolMint.svg b/public/icons/currencies/wSolMint.svg new file mode 100644 index 0000000..919c2bc --- /dev/null +++ b/public/icons/currencies/wSolMint.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/components/common/CurrencySelect/index.tsx b/src/components/common/CurrencySelect/index.tsx new file mode 100644 index 0000000..b36ed45 --- /dev/null +++ b/src/components/common/CurrencySelect/index.tsx @@ -0,0 +1,29 @@ +import { Select, SelectTrigger, SelectItem, SelectValue, SelectContent } from '@/components/ui/select.tsx'; +import { currencies, TCurrencies } from '@/constants/addresses.ts'; + +interface ICurrencySelect { + value: string; + onValueChange: (value: TCurrencies) => void; +} + +export const CurrencySelect = ({ value, onValueChange }: ICurrencySelect) => { + return ( + + ); +}; diff --git a/src/components/pages/game/game.tsx b/src/components/pages/game/game.tsx index ecf4c71..bbb914b 100644 --- a/src/components/pages/game/game.tsx +++ b/src/components/pages/game/game.tsx @@ -6,13 +6,13 @@ import { toast } from 'react-toastify'; import { z } from 'zod'; import { BaseTooltip } from '@/components/common/BaseTooltip'; -import Solana from '@/components/common/Svg/Solana.tsx'; +import { CurrencySelect } from '@/components/common/CurrencySelect'; import { Button } from '@/components/ui/button.tsx'; -import { env } from '@/env'; +import { currencies, TCurrencies } from '@/constants/addresses.ts'; import useStatus from '@/hooks/api/use-status'; import useMakePrediction from '@/hooks/contracts/write/use-make-prediction'; -import useSendSol from '@/hooks/contracts/write/use-send-sol'; -import { cn } from '@/lib/utils'; +import useSend from '@/hooks/contracts/write/use-send.ts'; +import { cn, showTxToast } from '@/lib/utils'; import { useWalletModalStore } from '@/store/wallet-modal.tsx'; const TarotRequestSchema = z.object({ @@ -46,7 +46,7 @@ export const GameSection = () => { const { setIsOpen } = useWalletModalStore(); const { mutateAsync: transfer, isSuccess, isPending, data: predictionAnswer } = useMakePrediction(); - const { mutateAsync: transferSol, isPending: isSolPending, isSuccess: isTipSuccess } = useSendSol(); + const { mutateAsync: transferCurrency, isPending: isSolPending, isSuccess: isTipSuccess } = useSend(); const { data: status } = useStatus(); const [selectedTip, setSelectedTip] = useState(0); @@ -56,6 +56,7 @@ export const GameSection = () => { const [showTip, setShowTip] = useState(false); const [isRetry, setRetry] = useState(false); const [dontReload, setDontReload] = useState(false); + const [currencyName, setCurrencyName] = useState(Object.keys(currencies)[0] as TCurrencies); const { register, @@ -69,7 +70,7 @@ export const GameSection = () => { const onSubmit: SubmitHandler = async (data, e) => { e?.preventDefault(); - await transfer(data.question.trim()); + await transfer({ question: data.question.trim(), tokenName: currencyName }); }; const handleTip = async () => { @@ -83,7 +84,9 @@ export const GameSection = () => { return; } - await transferSol(selectedTip); + await showTxToast('Tipping the Oracle', async () => { + await transferCurrency({ amount: selectedTip, tokenName: currencyName }); + }); }; useEffect(() => { @@ -213,11 +216,7 @@ export const GameSection = () => {
-
- -
{env.VITE_DEPOSIT_AMOUNT_SOL} SOL
-
- + {publicKey ? (