From 1c89350906c82c299910034bdd71d213431ab642 Mon Sep 17 00:00:00 2001 From: Devin Zuczek Date: Tue, 30 Jun 2026 18:05:16 -0400 Subject: [PATCH] fake currency for now --- apps/econ/src/econ.app.ts | 19 +++++++++++++++++-- apps/econ/src/test/integration/api.test.ts | 4 ++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/apps/econ/src/econ.app.ts b/apps/econ/src/econ.app.ts index 62c50ab..19e96bf 100644 --- a/apps/econ/src/econ.app.ts +++ b/apps/econ/src/econ.app.ts @@ -42,6 +42,19 @@ function unauthorized(c: Context) { return c.body(null, 401) } +/** RecNet currency types (the `CurrencyType` enum the client uses). */ +const CurrencyType = { + Invalid: 0, + LaserTagTickets: 1, + RecCenterTokens: 2, + LostSkullsGold: 100, + DraculaSilver: 101, + RecRoyaleSeason1: 200, + RoomCurrency: 300, + RoomInventoryItem: 301, + ProgressionEvent: 400, +} as const + const app = new Hono() .use( '*', @@ -144,12 +157,14 @@ const app = new Hono() return c.json([]) }) - // Token balance. [Authorize]; empty without a DB binding. + // Token balance. [Authorize]. The `2` in the path is the RecCenterTokens + // CurrencyType. The balance is a fake test value (a large amount) until a DB + // binding tracks real balances; Platform -2 means "all platforms". .get('/api/storefronts/v4/balance/2', async (c) => { const id = await authedId(c) if (id === null) return unauthorized(c) // TODO: query TokenBalances once a DB binding exists. - return c.json([]) + return c.json([{ CurrencyType: CurrencyType.RecCenterTokens, Platform: -2, Balance: 2147483648 }]) }) // Gift-drop storefront. Falls back to the bundled static catalog when no diff --git a/apps/econ/src/test/integration/api.test.ts b/apps/econ/src/test/integration/api.test.ts index 0a11d89..3bdabbd 100644 --- a/apps/econ/src/test/integration/api.test.ts +++ b/apps/econ/src/test/integration/api.test.ts @@ -186,14 +186,14 @@ describe('econ endpoints', () => { expect(await res.json()).toEqual([]) }) - test('GET /api/storefronts/v4/balance/2 401s without a token, returns []', async () => { + test('GET /api/storefronts/v4/balance/2 401s without a token, returns the token balance', async () => { const anon = await exports.default.fetch(`${ORIGIN}/api/storefronts/v4/balance/2`) expect(anon.status).toBe(401) const res = await exports.default.fetch(`${ORIGIN}/api/storefronts/v4/balance/2`, { headers: await bearer(), }) expect(res.status).toBe(200) - expect(await res.json()).toEqual([]) + expect(await res.json()).toEqual([{ CurrencyType: 2, Platform: -2, Balance: 2147483648 }]) }) test('GET /api/storefronts/v3/giftdropstore/3 returns the storefront catalog', async () => {