diff --git a/common/contract.ts b/common/contract.ts index 3120e16f..28096049 100644 --- a/common/contract.ts +++ b/common/contract.ts @@ -146,7 +146,7 @@ export type Bounty = { prizes: { [giverId: string]: number } - prizeTotal: number + totalPrizes: number } export type outcomeType = AnyOutcomeType['outcomeType'] diff --git a/common/new-contract.ts b/common/new-contract.ts index 7b681ccd..727816ff 100644 --- a/common/new-contract.ts +++ b/common/new-contract.ts @@ -171,7 +171,7 @@ function getBountyProps(ante: number, creator: User) { prizes: { [creator.id]: ante, }, - prizeTotal: ante, + totalPrizes: ante, } return system } diff --git a/functions/src/add-bounty.ts b/functions/src/add-bounty.ts index 2f5dee11..5c9e2400 100644 --- a/functions/src/add-bounty.ts +++ b/functions/src/add-bounty.ts @@ -34,6 +34,7 @@ export const addbounty = newEndpoint({}, async (req, auth) => { if (user.balance < amount) throw new APIError(400, 'Insufficient balance') + // TODO: Capture with txns? transaction.update(userDoc, { balance: user.balance - amount, totalDeposits: user.totalDeposits - amount, @@ -46,6 +47,7 @@ export const addbounty = newEndpoint({}, async (req, auth) => { ...contract.prizes, [user.id]: existingPrize + amount, }, + totalPrizes: contract.totalPrizes + amount, }) return { status: 'success' }