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

hicommonwealth / commonwealth / 12304263166

12 Dec 2024 08:28PM UTC coverage: 46.87%. First build
12304263166

Pull #10167

github

web-flow
Merge 8892fe0b8 into 807071c54
Pull Request #10167: Farcaster weighted voting

1192 of 2847 branches covered (41.87%)

Branch coverage included in aggregate %.

4 of 59 new or added lines in 5 files covered. (6.78%)

2447 of 4917 relevant lines covered (49.77%)

30.9 hits per line

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

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

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

11
// This webhook processes the "cast.created" event
12
// from a programmatic Neynar webhook for REPLIES to a cast
13
export function FarcasterReplyCastCreatedWebhook(): Command<
14
  typeof schemas.FarcasterCastCreatedWebhook
15
> {
16
  return {
×
17
    ...schemas.FarcasterCastCreatedWebhook,
18
    auth: [],
19
    body: async ({ payload }) => {
NEW
20
      mustExist('Farcaster Cast Parent Hash', payload.data.parent_hash);
×
NEW
21
      mustExist('Farcaster Cast Author FID', payload.data.author?.fid);
×
22

NEW
23
      const client = new NeynarAPIClient(config.CONTESTS.NEYNAR_API_KEY!);
×
24
      // get user verified address
NEW
25
      const { users } = await client.fetchBulkUsers([payload.data.author.fid]);
×
NEW
26
      const verified_address = users[0].verified_addresses.eth_addresses.at(0);
×
NEW
27
      if (!verified_address) {
×
NEW
28
        log.warn(
×
29
          'Farcaster verified address not found for reply cast created event- content will be ignored.',
30
        );
NEW
31
        return;
×
32
      }
33

34
      await emitEvent(
×
35
        models.Outbox,
36
        [
37
          {
38
            event_name: schemas.EventNames.FarcasterReplyCastCreated,
39
            event_payload: {
40
              ...payload.data,
41
              verified_address,
42
            },
43
          },
44
        ],
45
        null,
46
      );
47
    },
48
  };
49
}
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

© 2025 Coveralls, Inc