From 7770d7e83df01ca0aecda71dc5de0e08bb62e120 Mon Sep 17 00:00:00 2001 From: Marcin Date: Thu, 13 Feb 2025 16:47:27 +0100 Subject: [PATCH 1/3] 10928 Update Farcaster contest frame to use voting rules instead of prizes --- .../farcaster/frames/contest/contestCard.tsx | 6 +- .../frames/contest/contestPrizes.tsx | 123 ------------------ .../server/farcaster/frames/contest/index.ts | 4 +- .../farcaster/frames/contest/votingRules.tsx | 81 ++++++++++++ .../commonwealth/server/farcaster/router.tsx | 4 +- 5 files changed, 88 insertions(+), 130 deletions(-) delete mode 100644 packages/commonwealth/server/farcaster/frames/contest/contestPrizes.tsx create mode 100644 packages/commonwealth/server/farcaster/frames/contest/votingRules.tsx diff --git a/packages/commonwealth/server/farcaster/frames/contest/contestCard.tsx b/packages/commonwealth/server/farcaster/frames/contest/contestCard.tsx index 8a84de9b45d..a927ab70e83 100644 --- a/packages/commonwealth/server/farcaster/frames/contest/contestCard.tsx +++ b/packages/commonwealth/server/farcaster/frames/contest/contestCard.tsx @@ -121,11 +121,11 @@ export const contestCard = frames(async (ctx) => { Leaderboard , , , - ], - }; -}); diff --git a/packages/commonwealth/server/farcaster/frames/contest/index.ts b/packages/commonwealth/server/farcaster/frames/contest/index.ts index 0ecf4d434d2..5f46f4c17a9 100644 --- a/packages/commonwealth/server/farcaster/frames/contest/index.ts +++ b/packages/commonwealth/server/farcaster/frames/contest/index.ts @@ -1,4 +1,4 @@ import { contestCard } from './contestCard'; -import { contestPrizes } from './contestPrizes'; +import { votingRules } from './votingRules'; -export { contestCard, contestPrizes }; +export { contestCard, votingRules }; diff --git a/packages/commonwealth/server/farcaster/frames/contest/votingRules.tsx b/packages/commonwealth/server/farcaster/frames/contest/votingRules.tsx new file mode 100644 index 00000000000..85377919bfd --- /dev/null +++ b/packages/commonwealth/server/farcaster/frames/contest/votingRules.tsx @@ -0,0 +1,81 @@ +import { query } from '@hicommonwealth/core'; +import { Contest } from '@hicommonwealth/model'; +import { Button } from 'frames.js/express'; +import React from 'react'; +import { frames } from '../../config'; +import { FrameLayout } from '../../utils'; + +export const votingRules = frames(async (ctx) => { + const contest_address = ctx.url.pathname.split('/')[1]; + + const contestManager = await query(Contest.GetContest(), { + actor: { user: { email: '' } }, + payload: { contest_address, with_chain_node: true }, + }); + + if (!contestManager) { + return { + title: 'Contest not found', + image: ( + +

Try to run the contest again.

+
+ ), + }; + } + + return { + title: 'Voting Rules', + image: ( + +
+
    +
  • + • All votes are weighted by the token used to fund the contest +
  • +
  • + • Users must have the requisite token in their Farcaster verified + wallet to vote +
  • +
  • + • Add the "upvote content" action to add your votes to + the entries +
  • +
  • • Any reply to the frame is considered an entry
  • +
  • + • Check the leaderboard after voting to see if your votes were + applied +
  • +
+
+
+ ), + buttons: [ + , + ], + }; +}); diff --git a/packages/commonwealth/server/farcaster/router.tsx b/packages/commonwealth/server/farcaster/router.tsx index 6cb81f5eaa1..bc3cba32e67 100644 --- a/packages/commonwealth/server/farcaster/router.tsx +++ b/packages/commonwealth/server/farcaster/router.tsx @@ -1,11 +1,11 @@ import express from 'express'; -import { contestCard, contestPrizes } from './frames/contest'; +import { contestCard, votingRules } from './frames/contest'; const farcasterRouter = express.Router(); // WARNING: do not change these paths because cloudflare may route to it farcasterRouter.get('/:contest_address/contestCard', contestCard); farcasterRouter.post('/:contest_address/contestCard', contestCard); -farcasterRouter.post('/:contest_address/contestPrizes', contestPrizes); +farcasterRouter.post('/:contest_address/votingRules', votingRules); export default farcasterRouter; From ecacb86753e0b1429c65650cdb7582223be60533 Mon Sep 17 00:00:00 2001 From: Marcin Date: Thu, 13 Feb 2025 16:59:39 +0100 Subject: [PATCH 2/3] 10880 Update Farcaster contest frame end time display with timezone information --- .../server/farcaster/frames/contest/contestCard.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/commonwealth/server/farcaster/frames/contest/contestCard.tsx b/packages/commonwealth/server/farcaster/frames/contest/contestCard.tsx index a927ab70e83..be67b7436d2 100644 --- a/packages/commonwealth/server/farcaster/frames/contest/contestCard.tsx +++ b/packages/commonwealth/server/farcaster/frames/contest/contestCard.tsx @@ -57,6 +57,8 @@ export const contestCard = frames(async (ctx) => { const endTime = contestManager.contests?.[0]?.end_time; + console.log('endTime', endTime); + return { title: contestManager.name, image: ( @@ -87,7 +89,10 @@ export const contestCard = frames(async (ctx) => { lineHeight: '1.2', }} > - Submit entries by replying below until {endTime.toLocaleString()} + Submit entries by replying below until{' '} + {endTime.toLocaleString(undefined, { + timeZoneName: 'longGeneric', + })}

)} From 42076588c87ff95e2164d92b2adb5f4e01869286 Mon Sep 17 00:00:00 2001 From: Marcin Date: Fri, 14 Feb 2025 13:04:08 +0100 Subject: [PATCH 3/3] Remove debug console log from Farcaster contest card --- .../server/farcaster/frames/contest/contestCard.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/commonwealth/server/farcaster/frames/contest/contestCard.tsx b/packages/commonwealth/server/farcaster/frames/contest/contestCard.tsx index be67b7436d2..c6766addfc0 100644 --- a/packages/commonwealth/server/farcaster/frames/contest/contestCard.tsx +++ b/packages/commonwealth/server/farcaster/frames/contest/contestCard.tsx @@ -57,8 +57,6 @@ export const contestCard = frames(async (ctx) => { const endTime = contestManager.contests?.[0]?.end_time; - console.log('endTime', endTime); - return { title: contestManager.name, image: (