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

cartesi / rollups-explorer / 10667377776

02 Sep 2024 12:42PM UTC coverage: 93.408% (-0.4%) from 93.768%
10667377776

Pull #232

github

nevendyulgerov
feat(apps/web): Tweak import validations
Pull Request #232: #229 Add import and export for specifications

1217 of 1450 branches covered (83.93%)

Branch coverage included in aggregate %.

515 of 603 new or added lines in 8 files covered. (85.41%)

3 existing lines in 1 file now uncovered.

13053 of 13827 relevant lines covered (94.4%)

38.51 hits per line

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

92.86
/packages/ui/src/TransactionProgress.tsx
1
"use client";
1✔
2
import {
1✔
3
    Center,
1✔
4
    Code,
1✔
5
    Collapse,
1✔
6
    Group,
1✔
7
    Progress,
1✔
8
    Stack,
1✔
9
    Text,
1✔
10
    useMantineTheme,
1✔
11
} from "@mantine/core";
1✔
12
import { useDisclosure } from "@mantine/hooks";
1✔
13
import { FC } from "react";
1✔
14
import {
1✔
15
    TbCheck,
1✔
16
    TbChevronDown,
1✔
17
    TbChevronUp,
1✔
18
    TbExclamationCircle,
1✔
19
} from "react-icons/tb";
1✔
20
import { BaseError } from "viem";
1✔
21
import {
1✔
22
    TransactionStageStatus,
1✔
23
    TransactionWaitStatus,
1✔
24
} from "./TransactionStatus";
1✔
25

1✔
26
export type TransactionProgressProps = {
1✔
27
    prepare: TransactionStageStatus;
1✔
28
    execute: TransactionStageStatus;
1✔
29
    wait: TransactionWaitStatus;
1✔
30
    confirmationMessage?: string;
1✔
31
    defaultErrorMessage?: string;
1✔
32
};
1✔
33

1✔
34
const getShortErrorMessage = (error: Error | null): string | undefined => {
1✔
35
    if (error != null) {
2,964✔
36
        if (error instanceof BaseError) {
32!
37
            return error.shortMessage;
×
38
        }
×
39
        if (error.cause instanceof BaseError) {
32!
40
            return error.cause.shortMessage;
×
41
        }
×
42
        const be = error as BaseError;
32✔
43
        return be.shortMessage;
32✔
44
    }
32✔
45
    return undefined;
2,932✔
46
};
2,932✔
47

1✔
48
const getErrorMessage = (error: Error | null): string | undefined => {
1✔
49
    if (error != null) {
2,964✔
50
        return error.message;
32✔
51
    }
32✔
52
    return undefined;
2,932✔
53
};
2,932✔
54

1✔
55
export const TransactionProgress: FC<TransactionProgressProps> = ({
1✔
56
    prepare,
988✔
57
    execute,
988✔
58
    wait,
988✔
59
    confirmationMessage,
988✔
60
    defaultErrorMessage,
988✔
61
}) => {
988✔
62
    const theme = useMantineTheme();
988✔
63
    const successColor = theme.colors.teal[5];
988✔
64
    const errorColor = theme.colors.red[5];
988✔
65

988✔
66
    // customizable confirmation message
988✔
67
    confirmationMessage = confirmationMessage || "Transaction confirmed";
988✔
68

988✔
69
    // customizable default error message
988✔
70
    defaultErrorMessage = defaultErrorMessage || "Transaction failed";
988✔
71

988✔
72
    const [showError, { toggle: toggleError }] = useDisclosure(false);
988✔
73
    const isSuccess = wait.status == "success";
988✔
74
    const isError = !!prepare.error || !!execute.error || !!wait.error;
988✔
75
    const isMining = wait.fetchStatus === "fetching";
988✔
76
    const shortErrorMessage =
988✔
77
        getShortErrorMessage(prepare.error) ||
988✔
78
        getShortErrorMessage(execute.error) ||
988✔
79
        getShortErrorMessage(wait.error);
988✔
80
    const errorMessage =
988✔
81
        getErrorMessage(prepare.error) ||
988✔
82
        getErrorMessage(execute.error) ||
988✔
83
        getErrorMessage(wait.error);
988✔
84
    const isLoading = execute.status === "pending";
988✔
85

988✔
86
    return (
988✔
87
        <Stack gap={5}>
988✔
88
            <Center>
988✔
89
                {isLoading && <Text size="xs">Check wallet...</Text>}
988✔
90
                {isMining && <Text size="xs">Waiting for confirmation...</Text>}
988✔
91
                {isSuccess && (
988✔
92
                    <Group gap={5}>
29✔
93
                        <TbCheck color={successColor} />
29✔
94
                        <Text size="xs" c={successColor}>
29✔
95
                            {confirmationMessage}
29✔
96
                        </Text>
29✔
97
                    </Group>
29✔
98
                )}
988✔
99
                {isError && (
988✔
100
                    <Group gap={5}>
32✔
101
                        <TbExclamationCircle color={errorColor} />
32✔
102
                        <Text size="xs" c={errorColor}>
32✔
103
                            {shortErrorMessage || defaultErrorMessage}
32✔
104
                        </Text>
32✔
105
                        {errorMessage &&
32✔
106
                            (showError ? (
32!
107
                                <TbChevronUp
×
108
                                    color={errorColor}
×
109
                                    onClick={toggleError}
×
110
                                />
×
111
                            ) : (
32✔
112
                                <TbChevronDown
32✔
113
                                    color={errorColor}
32✔
114
                                    onClick={toggleError}
32✔
115
                                />
32✔
116
                            ))}
32✔
117
                    </Group>
32✔
118
                )}
988✔
119
            </Center>
988✔
120
            <Collapse in={showError}>
988✔
121
                <Code block variant="transparent" c={errorColor}>
988✔
122
                    {errorMessage}
988✔
123
                </Code>
988✔
124
            </Collapse>
988✔
125
            {(isLoading || isMining) && (
988✔
126
                <Progress value={100} striped animated size="sm" />
27✔
127
            )}
988✔
128
            {isSuccess && (
988✔
129
                <Progress value={100} size="sm" color={successColor} />
29✔
130
            )}
988✔
131
            {isError && <Progress value={100} size="sm" color={errorColor} />}
988✔
132
        </Stack>
988✔
133
    );
988✔
134
};
988✔
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