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

cartesi / rollups-explorer / 10138892735

29 Jul 2024 05:56AM UTC coverage: 92.455% (-0.9%) from 93.346%
10138892735

Pull #213

github

brunomenezes
feat: Integrate decoding spec + input-details-view. Improve error handling for Content component.
Pull Request #213: Feature/165 add decode specification v1

897 of 1067 branches covered (84.07%)

Branch coverage included in aggregate %.

1137 of 1303 new or added lines in 21 files covered. (87.26%)

2 existing lines in 1 file now uncovered.

10168 of 10901 relevant lines covered (93.28%)

48.08 hits per line

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

41.56
/apps/web/src/components/specification/utils.ts
1
import { isNotNilOrEmpty } from "ramda-adjunct";
1✔
2
import { SpecFormValues } from "./form/context";
1✔
3
import { Specification } from "./types";
1✔
4

1✔
5
/**
1✔
6
 * Replacer to be used with JSON.stringify as the default internal
1✔
7
 * parser does not deal with bigint yet.
1✔
8
 * @param key
1✔
9
 * @param value
1✔
10
 * @returns
1✔
11
 */
1✔
12
export const replacerForBigInt = (_key: any, value: any) => {
1✔
NEW
13
    return typeof value === "bigint" ? value.toString() : value;
×
NEW
14
};
×
15

1✔
16
export const stringifyContent = (value: Record<string, any>) =>
1✔
NEW
17
    JSON.stringify(value, replacerForBigInt, 2);
×
18

1✔
19
const Separator = "\n" as const;
1✔
20

1✔
21
/**
1✔
22
 * Expects a string with multiple ABI signatures in human readable format.
1✔
23
 * It will be splitted and trimmed removing extra whitespaces, returning an list of strings.
1✔
24
 * @param multiline String with human readable ABI signatures separated by a newline (i.e. \n)
1✔
25
 * @returns
1✔
26
 */
1✔
27
export const prepareSignatures = (multiline: string) =>
1✔
NEW
28
    multiline.split(Separator).map((signature) => signature?.trim());
×
29

1✔
30
/**
1✔
31
 * When the form values has the minimum necessary for the defined
1✔
32
 * specification mode it will return a Specification otherwise it returns null;
1✔
33
 * @param {SpecFormValues} values
1✔
34
 * @returns  {(Specification|null)}
1✔
35
 */
1✔
36
export const buildSpecification = (
1✔
NEW
37
    values: SpecFormValues,
×
NEW
38
): Specification | null => {
×
NEW
39
    const {
×
NEW
40
        mode,
×
NEW
41
        name,
×
NEW
42
        sliceInstructions,
×
NEW
43
        abi,
×
NEW
44
        abiParams,
×
NEW
45
        conditionals,
×
NEW
46
        sliceTarget,
×
NEW
47
        editingData,
×
NEW
48
        formMode,
×
NEW
49
    } = values;
×
NEW
50
    const version = 1;
×
NEW
51
    const timestamp = Date.now();
×
NEW
52
    const id =
×
NEW
53
        formMode === "EDITION" ? editingData?.originalSpec.id : undefined;
×
NEW
54
    const commons = { conditionals, timestamp, version, name, id };
×
NEW
55

×
NEW
56
    if (
×
NEW
57
        mode === "abi_params" &&
×
NEW
58
        (isNotNilOrEmpty(abiParams) || isNotNilOrEmpty(sliceInstructions))
×
NEW
59
    ) {
×
NEW
60
        return {
×
NEW
61
            ...commons,
×
NEW
62
            mode,
×
NEW
63
            abiParams,
×
NEW
64
            sliceInstructions:
×
NEW
65
                sliceInstructions.length > 0 ? sliceInstructions : undefined,
×
NEW
66
            sliceTarget: sliceTarget,
×
NEW
67
        } as Specification;
×
NEW
68
    } else if (mode === "json_abi" && isNotNilOrEmpty(abi)) {
×
NEW
69
        return {
×
NEW
70
            ...commons,
×
NEW
71
            mode,
×
NEW
72
            abi,
×
NEW
73
        } as Specification;
×
NEW
74
    }
×
NEW
75

×
NEW
76
    return null;
×
NEW
77
};
×
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