Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: update instruction components to use span instead of p and … #46

Merged
merged 2 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/components/common/section/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ const INSTRUCTIONS = [
description: (
<>
Once the payment is complete, the page will load your results <br />
<p className="mt-2">
<span className="mt-2">
<span className="font-bold">IMPORTANT:</span> DO NOT refresh the page if you’ve made a payment but haven’t
received the result yet. Wait until the process is complete
</p>
</span>
</>
),
},
Expand All @@ -37,10 +37,10 @@ const INSTRUCTIONS = [
{
subtitle: 'Ask another question:',
description: (
<p>
<span>
To start a new session, click &quot;
<span className="font-bold">Make a New Forecast</span>&quot; or refresh the page
</p>
</span>
),
},
];
Expand Down
7 changes: 5 additions & 2 deletions src/components/pages/game/game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const GameSection = () => {
const [isRetry, setRetry] = useState(false);
const [dontReload, setDontReload] = useState(false);
const [currencyName, setCurrencyName] = useState<Currencies>(Object.keys(currencies)[0] as Currencies);
const [question, setQuestion] = useState<string>('');

const {
register,
Expand All @@ -70,6 +71,7 @@ export const GameSection = () => {

const onSubmit: SubmitHandler<TarotRequestSchemaType> = async (data, e) => {
e?.preventDefault();
setQuestion(data.question.trim());
await transfer({ question: data.question.trim(), tokenName: currencyName });
};

Expand All @@ -93,8 +95,9 @@ export const GameSection = () => {
if (predictionAnswer) {
const timer = setTimeout(() => {
const formatted = predictionAnswer.answer.replaceAll('*', '');
const response = `Your answer:\n${formatted}\n\n\nYour question:\n${question}`;

setValue('question', formatted);
setValue('question', response);
setShowTip(true);
setRetry(true);
}, 3200);
Expand All @@ -103,7 +106,7 @@ export const GameSection = () => {
clearTimeout(timer);
};
}
}, [isSuccess, predictionAnswer, setValue, watch]);
}, [isSuccess, predictionAnswer, question, setValue, watch]);

useEffect(() => {
if (isTipSuccess) {
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/contracts/write/use-send-sol.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useWallet } from '@solana/wallet-adapter-react';
import { SystemProgram, Transaction } from '@solana/web3.js';
import { LAMPORTS_PER_SOL, SystemProgram, Transaction } from '@solana/web3.js';
import { useMutation } from '@tanstack/react-query';

import { useGetTokenAndSolBalance } from '../read/use-get-token-and-sol-balance';
Expand Down Expand Up @@ -38,8 +38,8 @@ const useSendSol = () => {
const fee = await rawTx.getEstimatedFee(connection);
const solBalance = tokens?.find((token) => token.mint === wSolMint.toBase58())?.amount;

if (fee && solBalance && Number(solBalance) + Number(amount) < fee) {
throw new Error('Insufficient SOL for transaction fee');
if (fee && solBalance && Number(solBalance) < fee + amount * LAMPORTS_PER_SOL) {
throw new Error('Insufficient funds');
}

return await sendAndConfirmTransaction(publicKey, rawTx, sendTransaction);
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/contracts/write/use-send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ const useSend = () => {
const fee = await rawTx.getEstimatedFee(connection);
const solBalance = tokens?.find((token) => token.mint === wSolMint.toBase58())?.amount;

if (fee && solBalance && Number(solBalance) + Number(amount) < fee) {
throw new Error('Insufficient SOL for transaction fee');
if (fee && solBalance && Number(solBalance) < fee) {
throw new Error('Insufficient funds');
}

return await sendAndConfirmTransaction(publicKey, rawTx, sendTransaction);
Expand Down
Loading