Only check stats if mana limit set
This commit is contained in:
parent
9eabd1a3e8
commit
b10e0b31e2
|
@ -77,12 +77,13 @@ export const placeBet = functions.runWith({ minInstances: 1 }).https.onCall(
|
|||
if (!answerSnap.exists)
|
||||
return { status: 'error', message: 'Invalid contract' }
|
||||
|
||||
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) {
|
||||
if (currentInvested + amount > manaLimitPerUser) {
|
||||
const manaAllowed = manaLimitPerUser - currentInvested
|
||||
return {
|
||||
status: 'error',
|
||||
|
@ -90,6 +91,7 @@ export const placeBet = functions.runWith({ minInstances: 1 }).https.onCall(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const newBetDoc = firestore
|
||||
.collection(`contracts/${contractId}/bets`)
|
||||
|
|
Loading…
Reference in New Issue
Block a user