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

cartesi / rollups-explorer / 8976881860

06 May 2024 10:58PM UTC coverage: 95.576%. Remained the same
8976881860

Pull #161

github

dandheedge
chore(packages/decoder): fix prettier path
Pull Request #161: #156 Voucher content decoding

499 of 600 branches covered (83.17%)

Branch coverage included in aggregate %.

6457 of 6678 relevant lines covered (96.69%)

21.18 hits per line

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

91.53
/apps/web/src/components/sendTransaction.tsx
1
"use client";
1✔
2
import {
1✔
3
    ERC20DepositForm,
1✔
4
    ERC721DepositForm,
1✔
5
    EtherDepositForm,
1✔
6
    RawInputForm,
1✔
7
} from "@cartesi/rollups-explorer-ui";
1✔
8
import { Select } from "@mantine/core";
1✔
9
import { useDebouncedValue } from "@mantine/hooks";
1✔
10
import { FC, useCallback, useState } from "react";
1✔
11
import { useSearchApplications } from "../hooks/useSearchApplications";
1✔
12
import { useSearchTokens } from "../hooks/useSearchTokens";
1✔
13
import { notifications } from "@mantine/notifications";
1✔
14

1✔
15
export type DepositType =
1✔
16
    | "ether"
1✔
17
    | "erc20"
1✔
18
    | "erc721"
1✔
19
    | "erc1155"
1✔
20
    | "relay"
1✔
21
    | "input";
1✔
22

1✔
23
interface DepositProps {
1✔
24
    initialDepositType?: DepositType;
1✔
25
}
1✔
26

1✔
27
const SendTransaction: FC<DepositProps> = ({
1✔
28
    initialDepositType = "ether",
12✔
29
}) => {
12✔
30
    const [depositType, setDepositType] =
12✔
31
        useState<DepositType>(initialDepositType);
12✔
32
    const [applicationId, setApplicationId] = useState<string>("");
12✔
33
    const [tokenId, setTokenId] = useState<string>("");
12✔
34
    const [debouncedApplicationId] = useDebouncedValue(applicationId, 400);
12✔
35
    const [debouncedTokenId] = useDebouncedValue(tokenId, 400);
12✔
36
    const { applications, fetching } = useSearchApplications({
12✔
37
        address: debouncedApplicationId,
12✔
38
    });
12✔
39
    const { tokens } = useSearchTokens({
12✔
40
        address: debouncedTokenId,
12✔
41
    });
12✔
42

12✔
43
    const onDepositErc721 = useCallback(() => {
12✔
44
        notifications.show({
×
45
            message: "Token was deposited successfully",
×
46
            color: "green",
×
47
            withBorder: true,
×
48
        });
×
49
    }, []);
12✔
50

12✔
51
    return (
12✔
52
        <>
12✔
53
            <Select
12✔
54
                label="Type"
12✔
55
                placeholder="Select deposit type"
12✔
56
                mb={16}
12✔
57
                allowDeselect={false}
12✔
58
                data={[
12✔
59
                    {
12✔
60
                        group: "Deposit",
12✔
61
                        items: [
12✔
62
                            { value: "ether", label: "Ether Deposit" },
12✔
63
                            { value: "erc20", label: "ERC-20 Deposit" },
12✔
64
                            { value: "erc721", label: "ERC-721 Deposit" },
12✔
65
                        ],
12✔
66
                    },
12✔
67
                    {
12✔
68
                        group: "Other",
12✔
69
                        items: [{ value: "input", label: "Raw Input" }],
12✔
70
                    },
12✔
71
                ]}
12✔
72
                value={depositType}
12✔
73
                onChange={(nextValue) => {
12✔
74
                    setDepositType(nextValue as DepositType);
×
75
                    setApplicationId("");
×
76
                }}
×
77
            />
12✔
78

12✔
79
            {depositType === "ether" ? (
12✔
80
                <EtherDepositForm
1✔
81
                    applications={applications}
1✔
82
                    isLoadingApplications={fetching}
1✔
83
                    onSearchApplications={setApplicationId}
1✔
84
                />
1✔
85
            ) : depositType === "erc20" ? (
11✔
86
                <ERC20DepositForm
9✔
87
                    tokens={tokens}
9✔
88
                    applications={applications}
9✔
89
                    isLoadingApplications={fetching}
9✔
90
                    onSearchApplications={setApplicationId}
9✔
91
                    onSearchTokens={setTokenId}
9✔
92
                />
9✔
93
            ) : depositType === "erc721" ? (
2✔
94
                <ERC721DepositForm
1✔
95
                    applications={applications}
1✔
96
                    isLoadingApplications={fetching}
1✔
97
                    onSearchApplications={setApplicationId}
1✔
98
                    onDeposit={onDepositErc721}
1✔
99
                />
1✔
100
            ) : depositType === "input" ? (
1✔
101
                <RawInputForm
1✔
102
                    applications={applications}
1✔
103
                    isLoadingApplications={fetching}
1✔
104
                    onSearchApplications={setApplicationId}
1✔
105
                />
1!
106
            ) : null}
×
107
        </>
12✔
108
    );
12✔
109
};
12✔
110
export default SendTransaction;
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