• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hicommonwealth / commonwealth / 12776988579

14 Jan 2025 09:48PM UTC coverage: 48.037% (-0.1%) from 48.168%
12776988579

Pull #10529

github

web-flow
Merge 3f194b364 into fc164f9cc
Pull Request #10529: Add contest bot webhook

1313 of 3050 branches covered (43.05%)

Branch coverage included in aggregate %.

6 of 35 new or added lines in 6 files covered. (17.14%)

1 existing line in 1 file now uncovered.

2591 of 5077 relevant lines covered (51.03%)

34.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

7.14
/libs/model/src/contest/FarcasterContestBotMentioned.command.ts
1
import { logger, type Command } from '@hicommonwealth/core';
2
import { config } from '@hicommonwealth/model';
3
import * as schemas from '@hicommonwealth/schemas';
4
import { NeynarAPIClient } from '@neynar/nodejs-sdk';
5
import { models } from '../database';
6
import { mustExist } from '../middleware/guards';
7
import { emitEvent, publishCast } from '../utils';
8

9
const log = logger(import.meta);
24✔
10

11
// This webhook processes the "cast.created" event
12
// triggered when the contest bot is mentioned on farcaster
13
export function FarcasterContestBotMentionedWebhook(): Command<
14
  typeof schemas.FarcasterContestBotMentionedWebhook
15
> {
NEW
16
  return {
×
17
    ...schemas.FarcasterContestBotMentionedWebhook,
18
    auth: [],
19
    body: async ({ payload }) => {
NEW
20
      mustExist('Farcaster Cast Author FID', payload.data.author?.fid);
×
21

NEW
22
      const client = new NeynarAPIClient(config.CONTESTS.NEYNAR_API_KEY!);
×
23
      // get user verified address
NEW
24
      const { users } = await client.fetchBulkUsers([payload.data.author.fid]);
×
NEW
25
      const verified_address = users[0].verified_addresses.eth_addresses.at(0);
×
NEW
26
      if (!verified_address) {
×
NEW
27
        log.warn(
×
28
          'Farcaster verified address not found for contest bot mentioned event- will be ignored.',
29
        );
NEW
30
        await publishCast(
×
31
          payload.data.hash,
32
          ({ username }) =>
NEW
33
            `Hey @${username}, you need a verified address for me to perform an action.`,
×
34
        );
NEW
35
        return;
×
36
      }
37

NEW
38
      await emitEvent(
×
39
        models.Outbox,
40
        [
41
          {
42
            event_name: schemas.EventNames.FarcasterContestBotMentioned,
43
            event_payload: {
44
              ...payload.data,
45
              verified_address,
46
            },
47
          },
48
        ],
49
        null,
50
      );
51
    },
52
  };
53
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc