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

cartesi / rollups-explorer / 7459483902

09 Jan 2024 09:59AM UTC coverage: 95.485%. First build
7459483902

Pull #98

github

nevendyulgerov
feat: Add coveralls badge
Pull Request #98: #97 Add build steps for generating and uploading test coverage

344 of 421 branches covered (0.0%)

Branch coverage included in aggregate %.

4858 of 5027 relevant lines covered (96.64%)

14.43 hits per line

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

86.34
/apps/web/src/components/inputRow.tsx
1
"use client";
1✔
2
import { erc20PortalAddress, etherPortalAddress } from "@cartesi/rollups-wagmi";
1✔
3
import {
1✔
4
    ActionIcon,
1✔
5
    Badge,
1✔
6
    Box,
1✔
7
    Collapse,
1✔
8
    Group,
1✔
9
    Paper,
1✔
10
    Table,
1✔
11
    Text,
1✔
12
} from "@mantine/core";
1✔
13
import { useDisclosure } from "@mantine/hooks";
1✔
14
import prettyMilliseconds from "pretty-ms";
1✔
15
import { FC } from "react";
1✔
16
import { TbArrowRight, TbFileText, TbX } from "react-icons/tb";
1✔
17
import { Address as AddressType, formatUnits, getAddress } from "viem";
1✔
18
import { InputItemFragment } from "../graphql";
1✔
19
import Address from "./address";
1✔
20
import InputDetailsView from "./inputDetailsView";
1✔
21

1✔
22
export type InputRowProps = {
1✔
23
    input: InputItemFragment;
1✔
24
    timeType: string;
1✔
25
    keepDataColVisible: boolean;
1✔
26
};
1✔
27

1✔
28
export type MethodResolver = (
1✔
29
    input: InputItemFragment,
1✔
30
) => string | undefined | false;
1✔
31

1✔
32
const etherDepositResolver: MethodResolver = (input) =>
1✔
33
    getAddress(input.msgSender) === etherPortalAddress && "depositEther";
6!
34
const erc20PortalResolver: MethodResolver = (input) =>
1✔
35
    getAddress(input.msgSender) === erc20PortalAddress && "depositERC20Tokens";
6!
36

1✔
37
const resolvers: MethodResolver[] = [etherDepositResolver, erc20PortalResolver];
1✔
38
const methodResolver: MethodResolver = (input) => {
1✔
39
    for (const resolver of resolvers) {
6✔
40
        const method = resolver(input);
12✔
41
        if (method) return method;
12!
42
    }
12✔
43
    return undefined;
6✔
44
};
6✔
45

1✔
46
const InputRow: FC<InputRowProps> = ({
1✔
47
    input,
6✔
48
    timeType,
6✔
49
    keepDataColVisible,
6✔
50
}) => {
6✔
51
    const [opened, { toggle }] = useDisclosure(false);
6✔
52
    const from = input.msgSender as AddressType;
6✔
53
    const to = input.application.id as AddressType;
6✔
54

6✔
55
    const erc20Deposit = (input: InputItemFragment) =>
6✔
56
        input.erc20Deposit ? (
6!
57
            <Text size="xs">
×
58
                {formatUnits(
×
59
                    input.erc20Deposit.amount,
×
60
                    input.erc20Deposit.token.decimals,
×
61
                )}{" "}
×
62
                {input.erc20Deposit.token.symbol}
×
63
            </Text>
×
64
        ) : (
6✔
65
            <></>
6✔
66
        );
6✔
67

6✔
68
    const method = (
6✔
69
        <Badge variant="default" style={{ textTransform: "none" }}>
6✔
70
            {methodResolver(input) ?? "?"}
6✔
71
        </Badge>
6✔
72
    );
6✔
73
    return (
6✔
74
        <>
6✔
75
            <Table.Tr>
6✔
76
                <Table.Td>
6✔
77
                    <Box style={{ minWidth: "max-content" }}>
6✔
78
                        {input.erc20Deposit ? (
6!
79
                            <Group>
×
80
                                <Address
×
81
                                    value={
×
82
                                        input.erc20Deposit.from as AddressType
×
83
                                    }
×
84
                                    icon
×
85
                                    shorten
×
86
                                />
×
87
                                <TbArrowRight />
×
88
                                <Address value={from} icon shorten />
×
89
                            </Group>
×
90
                        ) : (
6✔
91
                            <Address value={from} icon shorten />
6✔
92
                        )}
6✔
93
                    </Box>
6✔
94
                </Table.Td>
6✔
95
                <Table.Td>
6✔
96
                    <Box style={{ minWidth: "max-content" }}>
6✔
97
                        <Group justify="right">
6✔
98
                            {erc20Deposit(input)}
6✔
99
                            <TbArrowRight />
6✔
100
                        </Group>
6✔
101
                    </Box>
6✔
102
                </Table.Td>
6✔
103
                <Table.Td>
6✔
104
                    <Box style={{ minWidth: "max-content" }}>
6✔
105
                        <Address
6✔
106
                            value={to}
6✔
107
                            icon
6✔
108
                            href={`/applications/${to}`}
6✔
109
                            shorten
6✔
110
                        />
6✔
111
                    </Box>
6✔
112
                </Table.Td>
6✔
113
                <Table.Td>{method}</Table.Td>
6✔
114
                <Table.Td>
6✔
115
                    <Text>{input.index}</Text>
6✔
116
                </Table.Td>
6✔
117
                <Table.Td>
6✔
118
                    <Box style={{ minWidth: "max-content" }}>
6✔
119
                        <Text>
6✔
120
                            {timeType === "age"
6✔
121
                                ? `${prettyMilliseconds(
4✔
122
                                      Date.now() - input.timestamp * 1000,
4✔
123
                                      {
4✔
124
                                          unitCount: 2,
4✔
125
                                          secondsDecimalDigits: 0,
4✔
126
                                          verbose: true,
4✔
127
                                      },
4✔
128
                                  )} ago`
4✔
129
                                : new Date(
2✔
130
                                      input.timestamp * 1000,
2✔
131
                                  ).toISOString()}
2✔
132
                        </Text>
6✔
133
                    </Box>
6✔
134
                </Table.Td>
6✔
135
                <Table.Td
6✔
136
                    pos={keepDataColVisible ? "initial" : "sticky"}
6✔
137
                    top={0}
6✔
138
                    right={0}
6✔
139
                    p={0}
6✔
140
                >
6✔
141
                    <Paper
6✔
142
                        shadow={keepDataColVisible ? undefined : "xl"}
6✔
143
                        radius={0}
6✔
144
                        p="var(--table-vertical-spacing) var(--table-horizontal-spacing, var(--mantine-spacing-xs))"
6✔
145
                    >
6✔
146
                        <ActionIcon variant="default" onClick={toggle}>
6✔
147
                            {opened ? <TbX /> : <TbFileText />}
6!
148
                        </ActionIcon>
6✔
149
                    </Paper>
6✔
150
                </Table.Td>
6✔
151
            </Table.Tr>
6✔
152
            <Table.Tr></Table.Tr>
6✔
153
            <Table.Tr>
6✔
154
                <Table.Td colSpan={8} p={0}>
6✔
155
                    <Collapse in={opened}>
6✔
156
                        {opened && <InputDetailsView input={input} />}
6!
157
                    </Collapse>
6✔
158
                </Table.Td>
6✔
159
            </Table.Tr>
6✔
160
        </>
6✔
161
    );
6✔
162
};
6✔
163

1✔
164
export default InputRow;
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