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

cartesi / rollups-explorer / 11943333351

20 Nov 2024 11:09PM UTC coverage: 86.535% (-0.07%) from 86.605%
11943333351

push

github

brunomenezes
chore(ci): Set the Preview endpoint when available in the CI settings.

1276 of 1529 branches covered (83.45%)

Branch coverage included in aggregate %.

9077 of 10435 relevant lines covered (86.99%)

44.89 hits per line

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

97.18
/apps/web/src/lib/query.ts
1
import { isNotNilOrEmpty } from "ramda-adjunct";
1✔
2
import { isHash, isHex } from "viem";
1✔
3
import { InputWhereInput, RollupVersion } from "../graphql/explorer/types";
4

5
type QueryReturn = InputWhereInput;
6

7
/**
8
 *
9
 * @param {string} input
10
 * @param {string} appAddress
11
 * @param {string} chainId
12
 * @param {RollupVersion} appVersion
13
 * @returns {QueryReturn}
14
 */
15
export const checkQuery = (
1✔
16
    input: string,
11✔
17
    appAddress: string = "",
11✔
18
    chainId: string,
11✔
19
    appVersion?: RollupVersion,
11✔
20
): QueryReturn => {
11✔
21
    const chainQuery = { chain: { id_eq: chainId } };
11✔
22
    const versionQuery = isNotNilOrEmpty(appVersion)
11!
23
        ? { rollupVersion_eq: appVersion }
×
24
        : {};
11✔
25

26
    if (isNotNilOrEmpty(appAddress)) {
11✔
27
        const byAppIdQuery: QueryReturn = {
5✔
28
            application: {
5✔
29
                address_startsWith: appAddress,
5✔
30
                ...chainQuery,
5✔
31
                ...versionQuery,
5✔
32
            },
5✔
33
        };
5✔
34

35
        if (input) {
5✔
36
            const AND: QueryReturn[] = [byAppIdQuery];
4✔
37

38
            if (isHex(input)) {
4✔
39
                if (isHash(input)) {
3✔
40
                    AND.push({ transactionHash_eq: input, ...chainQuery });
1✔
41
                } else {
3✔
42
                    AND.push({ msgSender_startsWith: input, ...chainQuery });
2✔
43
                }
2✔
44
            } else {
4✔
45
                AND.push({ index_eq: parseInt(input), ...chainQuery });
1✔
46
            }
1✔
47
            return { AND };
4✔
48
        }
4✔
49
        return byAppIdQuery;
1✔
50
    } else if (input) {
11✔
51
        if (isHex(input)) {
5✔
52
            if (isHash(input)) {
3✔
53
                return { transactionHash_eq: input, ...chainQuery };
1✔
54
            } else {
3✔
55
                return {
2✔
56
                    OR: [
2✔
57
                        { msgSender_startsWith: input, ...chainQuery },
2✔
58
                        {
2✔
59
                            application: { address_startsWith: input },
2✔
60
                            ...chainQuery,
2✔
61
                        },
2✔
62
                    ],
2✔
63
                };
2✔
64
            }
2✔
65
        } else {
5✔
66
            return { index_eq: parseInt(input), ...chainQuery };
2✔
67
        }
2✔
68
    }
5✔
69

70
    return chainQuery;
1✔
71
};
1✔
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