Check creator balance again upon acceptance
This commit is contained in:
parent
f3704633ee
commit
d90901b4e3
|
@ -47,7 +47,7 @@ export const acceptchallenge = newEndpoint({}, async (req, auth) => {
|
|||
|
||||
const creatorDoc = firestore.doc(`users/${challenge.creatorId}`)
|
||||
const creatorSnap = await trans.get(creatorDoc)
|
||||
if (!creatorSnap.exists) throw new APIError(400, 'User not found.')
|
||||
if (!creatorSnap.exists) throw new APIError(400, 'Creator not found.')
|
||||
const creator = creatorSnap.data() as User
|
||||
|
||||
const {
|
||||
|
@ -61,6 +61,9 @@ export const acceptchallenge = newEndpoint({}, async (req, auth) => {
|
|||
if (user.balance < acceptorAmount)
|
||||
throw new APIError(400, 'Insufficient balance.')
|
||||
|
||||
if (creator.balance < creatorAmount)
|
||||
throw new APIError(400, 'Creator has insufficient balance.')
|
||||
|
||||
const contract = anyContract as CPMMBinaryContract
|
||||
const shares = (1 / creatorOutcomeProb) * creatorAmount
|
||||
const createdTime = Date.now()
|
||||
|
|
Loading…
Reference in New Issue
Block a user