From 6444b42a2aaa599cf1de91fa3d4dc20c947b2ee5 Mon Sep 17 00:00:00 2001 From: NikiTaysRD Date: Fri, 17 Jan 2025 18:19:07 +0200 Subject: [PATCH] feat: add currencies --- public/icons/currencies/usdcMint.svg | 12 +++++++ public/icons/currencies/usdtMint.svg | 11 +++++++ public/icons/currencies/wSolMint.svg | 20 +++++++++++ .../common/CurrencySelect/index.tsx | 33 +++++++++++-------- src/components/pages/game/game.tsx | 17 ++++++---- src/constants/addresses.ts | 7 +++- src/env.ts | 3 -- .../contracts/write/use-make-prediction.ts | 4 +-- src/hooks/contracts/write/use-send.ts | 3 +- 9 files changed, 82 insertions(+), 28 deletions(-) create mode 100644 public/icons/currencies/usdcMint.svg create mode 100644 public/icons/currencies/usdtMint.svg create mode 100644 public/icons/currencies/wSolMint.svg 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 index 69f983a..b36ed45 100644 --- a/src/components/common/CurrencySelect/index.tsx +++ b/src/components/common/CurrencySelect/index.tsx @@ -1,21 +1,28 @@ -import Solana from '@/components/common/Svg/Solana.tsx'; import { Select, SelectTrigger, SelectItem, SelectValue, SelectContent } from '@/components/ui/select.tsx'; +import { currencies, TCurrencies } from '@/constants/addresses.ts'; -export const CurrencySelect = () => { +interface ICurrencySelect { + value: string; + onValueChange: (value: TCurrencies) => void; +} + +export const CurrencySelect = ({ value, onValueChange }: ICurrencySelect) => { return ( - + - - -
- -
0.003
-
-
- Dark - System + + {Object.values(currencies).map((e, index) => { + return ( + +
+ currecy +
{e.defaultPrice}
+
+
+ ); + })}
); diff --git a/src/components/pages/game/game.tsx b/src/components/pages/game/game.tsx index f4a9f70..da27e43 100644 --- a/src/components/pages/game/game.tsx +++ b/src/components/pages/game/game.tsx @@ -7,12 +7,12 @@ import { z } from 'zod'; import { BaseTooltip } from '@/components/common/BaseTooltip'; import { CurrencySelect } from '@/components/common/CurrencySelect'; -import Solana from '@/components/common/Svg/Solana.tsx'; import { Button } from '@/components/ui/button.tsx'; +import { currencies, TCurrencies } from '@/constants/addresses.ts'; import useStatus from '@/hooks/api/use-status'; import useMakePrediction from '@/hooks/contracts/write/use-make-prediction'; import useSend from '@/hooks/contracts/write/use-send.ts'; -import { cn } from '@/lib/utils'; +import { cn, showTxToast } from '@/lib/utils'; import { useWalletModalStore } from '@/store/wallet-modal.tsx'; const TarotRequestSchema = z.object({ @@ -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({ question: data.question.trim(), tokenName: 'usdcMint' }); + await transfer({ question: data.question.trim(), tokenName: currencyName }); }; const handleTip = async () => { @@ -83,7 +84,9 @@ export const GameSection = () => { return; } - await transferCurrency({ amount: selectedTip, tokenName: 'usdcMint' }); + await showTxToast('Sending Tip to the Oracle', async () => { + await transferCurrency({ amount: selectedTip, tokenName: currencyName }); + }); }; useEffect(() => { @@ -213,7 +216,7 @@ export const GameSection = () => {
- + {publicKey ? (