From 55eaa89238422582f6e07272e8a148a2ff700e26 Mon Sep 17 00:00:00 2001 From: David Chee Date: Mon, 16 Sep 2024 18:43:39 -0700 Subject: [PATCH] update place-bet.ts --- backend/api/src/place-bet.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/api/src/place-bet.ts b/backend/api/src/place-bet.ts index afa78fd2eb..7401b242c2 100644 --- a/backend/api/src/place-bet.ts +++ b/backend/api/src/place-bet.ts @@ -290,7 +290,12 @@ export const fetchContractBetDataAndValidate = async ( contract.token === 'CASH' ? bet.cash_balance : bet.balance, ]) ) + const unfilledBetUserIds = Object.keys(balanceByUserId) + if (isAdminId(uid) && contract.token === 'CASH') { + throw new APIError(403, 'Admins cannot trade on sweepstakes markets.') + } + const balance = contract.token === 'CASH' ? user.cashBalance : user.balance if (amount !== undefined && balance < amount) throw new APIError(403, 'Insufficient balance.') @@ -303,8 +308,8 @@ export const fetchContractBetDataAndValidate = async ( 'You must be kyc verified to trade on sweepstakes markets.' ) } - if (BANNED_TRADING_USER_IDS.includes(user.id) || user.userDeleted) { - throw new APIError(403, 'You are banned or deleted. And not #blessed.') + if (user.isBannedFromTrading || user.userDeleted) { + throw new APIError(403, 'You are banned or deleted.') } log( `Loaded user ${user.username} with id ${user.id} betting on slug ${contract.slug} with contract id: ${contract.id}.`