From b10e0b31e278436a886fd073b7a2c16340f5f714 Mon Sep 17 00:00:00 2001 From: Ian Philips Date: Mon, 9 May 2022 10:05:53 -0400 Subject: [PATCH] Only check stats if mana limit set --- functions/src/place-bet.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/functions/src/place-bet.ts b/functions/src/place-bet.ts index 6f968ac9..8fff361e 100644 --- a/functions/src/place-bet.ts +++ b/functions/src/place-bet.ts @@ -77,16 +77,18 @@ export const placeBet = functions.runWith({ minInstances: 1 }).https.onCall( if (!answerSnap.exists) return { status: 'error', message: 'Invalid contract' } - const contractMetrics = getContractBetMetrics(contract, yourBets) - const currentInvested = contractMetrics.currentInvested - console.log('user current invested amount', currentInvested) - console.log('mana limit:', manaLimitPerUser) + if (manaLimitPerUser) { + const contractMetrics = getContractBetMetrics(contract, yourBets) + const currentInvested = contractMetrics.currentInvested + console.log('user current invested amount', currentInvested) + console.log('mana limit:', manaLimitPerUser) - if (manaLimitPerUser && currentInvested + amount > manaLimitPerUser) { - const manaAllowed = manaLimitPerUser - currentInvested - return { - status: 'error', - message: `Market bet cap is M$${manaLimitPerUser}, you've M$${manaAllowed} left`, + if (currentInvested + amount > manaLimitPerUser) { + const manaAllowed = manaLimitPerUser - currentInvested + return { + status: 'error', + message: `Market bet cap is M$${manaLimitPerUser}, you've M$${manaAllowed} left`, + } } } }