From 6ac129a0b8f52eefb45a142ac42ea84061f4e408 Mon Sep 17 00:00:00 2001 From: Marshall Polaris Date: Sun, 12 Jun 2022 14:23:23 -0700 Subject: [PATCH] Validate that user can pay for market (#487) --- functions/src/create-contract.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/functions/src/create-contract.ts b/functions/src/create-contract.ts index e8ac0307..645b5544 100644 --- a/functions/src/create-contract.ts +++ b/functions/src/create-contract.ts @@ -87,6 +87,10 @@ export const createmarket = newEndpoint(['POST'], async (req, auth) => { const ante = FIXED_ANTE + // TODO: this is broken because it's not in a transaction + if (ante > user.balance && !isFree) + throw new APIError(400, `Balance must be at least ${ante}.`) + console.log( 'creating contract for', user.username,