Skip to content
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
50 changes: 37 additions & 13 deletions src/components/pages/game/game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@
const pendingFund = useRef(false);

const privyWallet = walletsReady
? (wallets.find((w) => 'isPrivyWallet' in w.standardWallet && (w.standardWallet as { isPrivyWallet: boolean }).isPrivyWallet) ?? null)
? (wallets.find(
(w) =>

Check failure on line 81 in src/components/pages/game/game.tsx

View workflow job for this annotation

GitHub Actions / main

Replace `⏎··········'isPrivyWallet'·in·w.standardWallet·&&⏎·········` with `·'isPrivyWallet'·in·w.standardWallet·&&`
'isPrivyWallet' in w.standardWallet &&
(w.standardWallet as { isPrivyWallet: boolean }).isPrivyWallet,
) ?? null)
: null;

const isMd = useBreakpoint('md');
Expand Down Expand Up @@ -232,7 +236,12 @@
setRetry(false);
const trimmedQuestion = data.question.trim();
const amount = paymentPrices?.[currencyName] ?? currencies[currencyName].defaultPrice;
const result = await privyTransfer({ question: trimmedQuestion, tokenName: currencyName, amount, onStep: setLoadingStep });
const result = await privyTransfer({
question: trimmedQuestion,
tokenName: currencyName,
amount,
onStep: setLoadingStep,
});
if (!result) return;
setDisplayedTarots(result.tarots);
predictionResponseTimer.current = setTimeout(() => {
Expand Down Expand Up @@ -301,8 +310,12 @@
setLoadingStep('shuffling');

stepTimers.current.push(
setTimeout(() => { setLoadingStep('drawing'); }, 1600),
setTimeout(() => { setLoadingStep('consulting'); }, 3200),
setTimeout(() => {
setLoadingStep('drawing');
}, 1600),
setTimeout(() => {
setLoadingStep('consulting');
}, 3200),
);

demoTimer.current = setTimeout(() => {
Expand Down Expand Up @@ -371,15 +384,18 @@

useEffect(() => {
if (!authenticated || !walletsReady || privyWallet) return;
createWallet().catch(() => {});
createWallet().catch((_e: unknown) => {});

Check failure on line 387 in src/components/pages/game/game.tsx

View workflow job for this annotation

GitHub Actions / main

Unexpected empty arrow function

Check failure on line 387 in src/components/pages/game/game.tsx

View workflow job for this annotation

GitHub Actions / main

'_e' is defined but never used
}, [authenticated, walletsReady, privyWallet, createWallet]);

useEffect(() => {
if (!pendingFund.current || !authenticated || !walletsReady) return;
const target = privyWallet?.address ?? publicKey?.toBase58();
if (!target) return;
pendingFund.current = false;
fundWallet({ address: target, options: { defaultFundingMethod: 'card', card: { preferredProvider: 'moonpay' } } }).catch((error: unknown) => {
fundWallet({
address: target,
options: { defaultFundingMethod: 'card', card: { preferredProvider: 'moonpay' } },
}).catch((error: unknown) => {
console.error('Fund wallet error:', error);
toast.error('Could not open top-up modal. Please try again.');
});
Expand All @@ -397,7 +413,10 @@
return;
}
try {
await fundWallet({ address: target, options: { defaultFundingMethod: 'card', card: { preferredProvider: 'moonpay' } } });
await fundWallet({
address: target,
options: { defaultFundingMethod: 'card', card: { preferredProvider: 'moonpay' } },
});
} catch (error: unknown) {
console.error('Fund wallet error:', error);
toast.error('Could not open top-up modal. Please try again.');
Expand All @@ -417,10 +436,7 @@
{activeTarots.map((e, idx) => (
<img
key={e.id}
className={cn(
'mx-auto rounded-[8px] max-md:h-[485px] max-md:w-[280px]',
e.reverted && 'rotate-180',
)}
className={cn('mx-auto rounded-[8px] max-md:h-[485px] max-md:w-[280px]', e.reverted && 'rotate-180')}
style={{ animation: CARD_ANIMATIONS[idx] }}
src={`images/cards/${e.id}.png`}
alt={`Card ${e.id}`}
Expand All @@ -447,7 +463,10 @@
</div>

{loadingStep && (
<p key={loadingStep} className="animate-in fade-in duration-500 text-center font-inknut text-[18px] italic text-[#621421]">
<p
key={loadingStep}
className="animate-in fade-in text-center font-inknut text-[18px] italic text-[#621421] duration-500"
>
{STEP_MESSAGES[loadingStep]}
</p>
)}
Expand Down Expand Up @@ -526,10 +545,15 @@
variant="outline"
onClick={
isRetry
? () => { setDontReload(true); setTimeout(() => { window.location.reload(); }, 10); }
? () => {
setDontReload(true);
setTimeout(() => {
window.location.reload();
}, 10);
}
: handleSubmit(onSubmit)
}
disabled={isPending || isPrivyPending || isDemoPending || status?.isShutDown || !paymentPrices}

Check failure on line 556 in src/components/pages/game/game.tsx

View workflow job for this annotation

GitHub Actions / main

Prefer using nullish coalescing operator (`??`) instead of a logical or (`||`), as it is a safer operator
className="h-full w-full bg-[#9DA990] text-[22px]"
>
{isRetry ? 'Make a new Forecast' : 'Make a Forecast'}
Expand All @@ -541,7 +565,7 @@
variant="outline"
onClick={
isRetry
? () => { setDontReload(true); setTimeout(() => { window.location.reload(); }, 10); }

Check failure on line 568 in src/components/pages/game/game.tsx

View workflow job for this annotation

GitHub Actions / main

Replace `·setDontReload(true);·setTimeout(()·=>·{·window.location.reload();·},·10);` with `⏎····················setDontReload(true);⏎····················setTimeout(()·=>·{⏎······················window.location.reload();⏎····················},·10);⏎·················`
: handleSubmit(onPrivySubmit)
}
disabled={isPrivyPending || isPending || isDemoPending}
Expand All @@ -553,7 +577,7 @@
<Button
size="responsive"
variant="outline"
onClick={() => { setIsOpen(true); }}

Check failure on line 580 in src/components/pages/game/game.tsx

View workflow job for this annotation

GitHub Actions / main

Replace `·setIsOpen(true);` with `⏎··············setIsOpen(true);⏎···········`
className="bg-[#9DA990] text-[22px]"
>
Connect Wallet
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/contracts/write/use-privy-send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const usePrivySend = () => {
options: { skipPreflight: true, commitment: 'finalized' },
});

return bs58.default.encode(signature);
return bs58.encode(signature);
}

const { address: mint, decimals } = currencies[tokenName];
Expand Down Expand Up @@ -108,7 +108,7 @@ const usePrivySend = () => {
options: { skipPreflight: true, commitment: 'finalized' },
});

return bs58.default.encode(signature);
return bs58.encode(signature);
},

onError(error) {
Expand Down
1 change: 1 addition & 0 deletions src/providers/solana-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const SolanaProvider = ({ children }: PropsWithChildren) => {
<PrivyProvider
appId={env.VITE_PRIVY_APP_ID}
config={{
loginMethods: ['email'],
externalWallets: {
solana: {
connectors: toSolanaWalletConnectors(),
Expand Down
Loading