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

hicommonwealth / commonwealth / 19508639478

19 Nov 2025 04:27PM UTC coverage: 37.649%. Remained the same
19508639478

push

github

web-flow
fix updates with event id (#13205)

Co-authored-by: rotorsoft <rotorsoft@outlook.com>

2041 of 5832 branches covered (35.0%)

Branch coverage included in aggregate %.

0 of 2 new or added lines in 2 files covered. (0.0%)

3 existing lines in 1 file now uncovered.

3574 of 9082 relevant lines covered (39.35%)

45.82 hits per line

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

4.55
/libs/model/src/aggregates/token-allocation/UpdateClaimTransactionHash.command.ts
1
import { InvalidState, logger, type Command } from '@hicommonwealth/core';
2
import * as schemas from '@hicommonwealth/schemas';
3
import { QueryTypes } from 'sequelize';
4
import { models } from '../../database';
5
import { validateClaimTxnHash } from '../../utils/validateClaimTxnHash';
6

7
const log = logger(import.meta);
31✔
8

9
export function UpdateClaimTransactionHash(): Command<
10
  typeof schemas.UpdateClaimTransactionHash
11
> {
12
  return {
×
13
    ...schemas.UpdateClaimTransactionHash,
14
    auth: [],
15
    secure: true,
16
    body: async ({ payload, actor }) => {
NEW
17
      const { event_id, transaction_hash } = payload;
×
18

19
      const claimAddress = await models.ClaimAddresses.findOne({
×
20
        where: {
21
          event_id,
22
          user_id: actor.user.id,
23
        },
24
      });
25

26
      if (!claimAddress) {
×
27
        log.error('Claim address not found for user', undefined, {
×
28
          user_id: actor.user.id,
29
        });
30
        throw new InvalidState('Claim address not found');
×
31
      }
32

33
      if (claimAddress.magna_claim_tx_hash && claimAddress.magna_claim_tx_at) {
×
34
        return false;
×
35
      }
36

37
      if (!claimAddress.address) {
×
38
        throw new InvalidState(
×
39
          'Cannot set transaction hash without a claim address',
40
        );
41
      }
42

43
      const txnAt = await validateClaimTxnHash(
×
44
        transaction_hash,
45
        claimAddress.address,
46
      );
47

48
      const [, updated] = await models.sequelize.query(
×
49
        `
50
          UPDATE "ClaimAddresses"
51
          SET 
52
            magna_claim_tx_hash = :transaction_hash,
53
            magna_claim_tx_at = :transaction_at
54
          WHERE
55
            event_id = :event_id
56
            user_id = :user_id
57
            AND magna_claimed_at IS NOT NULL
58
            AND magna_claim_data IS NOT NULL
59
            AND magna_claim_tx_hash IS NULL;
60
        `,
61
        {
62
          type: QueryTypes.UPDATE,
63
          replacements: {
64
            event_id,
65
            user_id: actor.user.id,
66
            transaction_hash,
67
            transaction_at: txnAt,
68
          },
69
        },
70
      );
71

72
      return updated > 0;
×
73
    },
74
  };
75
}
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