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

cartesi / rollups-explorer / 11826960107

13 Nov 2024 10:31PM CUT coverage: 85.956% (-0.6%) from 86.605%
11826960107

Pull #256

github

nevendyulgerov
test(apps/web): Tweak layout for tuple inputs
Pull Request #256: #251 Add ABI encoding for raw input form

1368 of 1630 branches covered (83.93%)

Branch coverage included in aggregate %.

793 of 984 new or added lines in 13 files covered. (80.59%)

9465 of 10973 relevant lines covered (86.26%)

47.16 hits per line

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

9.62
/packages/ui/src/GenericInputForm/TupleComponents.tsx
1
import React, { FC, Fragment } from "react";
1✔
2
import { InputLabel } from "./FunctionSignature";
1✔
3
import { Fieldset, FieldsetProps, TextInput } from "@mantine/core";
1✔
4
import { useFormContext } from "./context";
1✔
5
import { AbiInputParam } from "./types";
6

7
interface TupleComponentsProps extends FieldsetProps {
8
    input: AbiInputParam;
9
}
10

11
export const TupleComponents: FC<TupleComponentsProps> = (props) => {
1✔
NEW
12
    const form = useFormContext();
×
NEW
13
    const { input, ...restProps } = props;
×
NEW
14
    const { value: abiFunctionParams } =
×
NEW
15
        form.getInputProps("abiFunctionParams");
×
NEW
16
    const firstStandardInput = input.components.find((c) => c.type !== "tuple");
×
NEW
17
    const firstStandardInputIndex = input.components.findIndex(
×
NEW
18
        (c) =>
×
NEW
19
            c.name == firstStandardInput?.name &&
×
NEW
20
            c.type === firstStandardInput?.type,
×
NEW
21
    );
×
22

NEW
23
    return (
×
NEW
24
        <Fieldset {...restProps} legend={<InputLabel input={input} />}>
×
NEW
25
            {input.components.map((component, componentIndex) => {
×
NEW
26
                const isFirstStandardInput =
×
NEW
27
                    componentIndex === firstStandardInputIndex;
×
NEW
28
                const targetIndex = abiFunctionParams.findIndex(
×
NEW
29
                    (p: AbiInputParam) =>
×
NEW
30
                        p.tupleName === input.name &&
×
NEW
31
                        p.type === component.type &&
×
NEW
32
                        p.name === component.name,
×
NEW
33
                );
×
34

NEW
35
                return (
×
NEW
36
                    <Fragment
×
NEW
37
                        key={`${input.name}-${input.type}-${component.name}-${component.type}`}
×
38
                    >
NEW
39
                        {component.type === "tuple" ? (
×
NEW
40
                            <TupleComponents
×
NEW
41
                                input={component}
×
NEW
42
                                mt={componentIndex > 0 ? 16 : 0}
×
NEW
43
                                mb={
×
NEW
44
                                    input.components[componentIndex + 1]
×
NEW
45
                                        ? 16
×
NEW
46
                                        : 0
×
47
                                }
NEW
48
                            />
×
49
                        ) : (
NEW
50
                            <TextInput
×
NEW
51
                                key={`${component.name}-${component.type}`}
×
NEW
52
                                label={<InputLabel input={component} />}
×
NEW
53
                                placeholder={`Enter ${component.type} value`}
×
NEW
54
                                mt={isFirstStandardInput ? 0 : 16}
×
NEW
55
                                withAsterisk
×
NEW
56
                                {...form.getInputProps(
×
NEW
57
                                    `abiFunctionParams.${targetIndex}.value`,
×
NEW
58
                                )}
×
NEW
59
                            />
×
60
                        )}
NEW
61
                    </Fragment>
×
62
                );
NEW
63
            })}
×
NEW
64
        </Fieldset>
×
65
    );
NEW
66
};
×
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