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

cartesi / rollups-explorer / 11325553061

14 Oct 2024 10:19AM UTC coverage: 84.745% (-1.7%) from 86.415%
11325553061

Pull #256

github

nevendyulgerov
test(apps/web): Add unit tests for GenericInput form
Pull Request #256: #251 Add ABI encoding for raw input form

1303 of 1565 branches covered (83.26%)

Branch coverage included in aggregate %.

710 of 904 new or added lines in 13 files covered. (78.54%)

135 existing lines in 1 file now uncovered.

9185 of 10811 relevant lines covered (84.96%)

46.11 hits per line

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

78.67
/packages/ui/src/GenericInputForm/utils.ts
1
import {
1✔
2
    encodeAbiParameters,
3
    getAddress,
4
    parseAbi,
5
    parseAbiParameters,
6
} from "viem";
1✔
7
import { AbiValueParameter, FormSpecification } from "./types";
8
import { prepareSignatures } from "web/src/components/specification/utils";
1✔
9
import { isArray, isBlank, isObject } from "ramda-adjunct";
1✔
10

11
export const encodeFunctionParams = (params: AbiValueParameter[]) => {
1✔
12
    const values = params.map((param) => {
1✔
NEW
13
        switch (param.type) {
×
NEW
14
            case "bool":
×
NEW
15
                return param.value === "true";
×
NEW
16
            case "address":
×
NEW
17
                return getAddress(param.value);
×
NEW
18
            case "uint":
×
NEW
19
            case "uint8":
×
NEW
20
            case "uint16":
×
NEW
21
            case "uint32":
×
NEW
22
            case "uint64":
×
NEW
23
            case "uint128":
×
NEW
24
            case "uint256":
×
NEW
25
                return BigInt(param.value);
×
NEW
26
            default:
×
NEW
27
                return param.value;
×
NEW
28
        }
×
29
    });
1✔
30

31
    return encodeAbiParameters(params, values);
1✔
32
};
1✔
33

34
export const generateHumanAbiFormSpecification = (humanAbi: string) => {
1✔
35
    if (isBlank(humanAbi)) {
83✔
36
        return undefined;
24✔
37
    }
24✔
38

39
    const readableList = prepareSignatures(humanAbi);
59✔
40
    let generatedAbi;
59✔
41
    try {
59✔
42
        generatedAbi = parseAbi(readableList);
59✔
43
    } catch (err) {}
83✔
44

45
    return isObject(generatedAbi)
59✔
46
        ? ({
55✔
47
              id: new Date().getTime().toString(),
55✔
48
              name: "Generated specification",
55✔
49
              abi: generatedAbi,
55✔
50
          } as FormSpecification)
55✔
51
        : undefined;
4✔
52
};
83✔
53

54
export const generateAbiParamFormSpecification = (abiParam: string) => {
1✔
55
    let abiParameters;
87✔
56

57
    try {
87✔
58
        abiParameters = parseAbiParameters(abiParam);
87✔
59
    } catch (err) {}
87✔
60

61
    return isArray(abiParameters)
87✔
62
        ? ({
52✔
63
              id: new Date().getTime().toString(),
52✔
64
              name: "Generated specification",
52✔
65
              abi: [
52✔
66
                  {
52✔
67
                      inputs: abiParameters,
52✔
68
                      name: "",
52✔
69
                      outputs: [],
52✔
70
                      stateMutability: "view",
52✔
71
                      type: "function",
52✔
72
                  },
52✔
73
              ],
52✔
74
          } as FormSpecification)
52✔
75
        : undefined;
35✔
76
};
87✔
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