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

cartesi / rollups-explorer / 8329358159

18 Mar 2024 03:34PM CUT coverage: 94.682% (-0.3%) from 94.937%
8329358159

Pull #140

github

nevendyulgerov
feat: Update lock file
Pull Request #140: #130 Upgrade rainbowkit wagmi viem packages

461 of 567 branches covered (81.31%)

Branch coverage included in aggregate %.

198 of 219 new or added lines in 13 files covered. (90.41%)

7 existing lines in 1 file now uncovered.

6376 of 6654 relevant lines covered (95.82%)

15.88 hits per line

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

68.71
/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) {
582!
36
        if (error instanceof BaseError) {
×
37
            return error.shortMessage;
×
38
        }
×
39
        if (error.cause instanceof BaseError) {
×
40
            return error.cause.shortMessage;
×
41
        }
×
42
        const be = error as BaseError;
×
43
        return be.shortMessage;
×
44
    }
×
45
    return undefined;
582✔
46
};
582✔
47

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

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

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

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

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

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