From 6cc33e4b9e34aa3f60747c92a3b7eec5ed282fed Mon Sep 17 00:00:00 2001 From: imollov Date: Fri, 9 Feb 2024 14:44:41 +0200 Subject: [PATCH] fix(app): test mode game register --- app/src/components/place-bet-button.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/components/place-bet-button.tsx b/app/src/components/place-bet-button.tsx index 4cfda0a..eca386b 100644 --- a/app/src/components/place-bet-button.tsx +++ b/app/src/components/place-bet-button.tsx @@ -1,6 +1,7 @@ 'use client' import { useState } from 'react' +import { useSearchParams } from 'next/navigation' import { formatEther, parseEther } from 'viem' import { useAccount, useBalance } from 'wagmi' import { @@ -28,6 +29,9 @@ export default function PlaceBetButton({ const { data } = useBalance({ address }) const { predictions, setPredictions } = useLocalStateContext() + const searchParams = useSearchParams() + const testMode = searchParams.get('mode') === 'test' + const placePredictions = async () => { setError(null) if (predictions.some((p) => p.wager === undefined || p.wager <= 0)) { @@ -79,6 +83,10 @@ export default function PlaceBetButton({ args: [gameId], }) if (game.externalId === BigInt(0)) { + // Bypassing the registration guard for test mode + const timestamp = testMode + ? BigInt(Math.floor(Date.now() / 1000) + 300) + : BigInt(prediction.game.timestamp) const config = await prepareWriteContract({ address: contractAddress, abi: sportsPredictionGameABI, @@ -86,7 +94,7 @@ export default function PlaceBetButton({ args: [ BigInt(prediction.game.sportId), BigInt(prediction.game.id), - BigInt(prediction.game.timestamp), + timestamp, winnerToResult[prediction.predictedWinner], ], value: parseEther(`${prediction.wager ?? 0}`),