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

cartesi / rollups-explorer / 14397356153

11 Apr 2025 06:51AM UTC coverage: 87.199% (+1.9%) from 85.294%
14397356153

Pull #269

github

brunomenezes
chore: Update explorer Dockerfile instructions, rename .env.sunodo to .env.cartesi.
Pull Request #269: Feat: Support rollups v2

1615 of 1880 branches covered (85.9%)

Branch coverage included in aggregate %.

2631 of 2762 new or added lines in 45 files covered. (95.26%)

3 existing lines in 2 files now uncovered.

11028 of 12619 relevant lines covered (87.39%)

59.09 hits per line

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

95.17
/packages/ui/src/AddressRelayForm.tsx
1
import {
1✔
2
    useSimulateDAppAddressRelayRelayDAppAddress,
3
    useWriteDAppAddressRelayRelayDAppAddress,
4
} from "@cartesi/rollups-wagmi";
1✔
5
import { Alert, Button, Collapse, Group, Loader, Stack } from "@mantine/core";
1✔
6
import { useForm } from "@mantine/form";
1✔
7
import { FC, useEffect } from "react";
1✔
8
import { TbAlertCircle, TbCheck } from "react-icons/tb";
1✔
9
import { BaseError, getAddress, isAddress, zeroAddress } from "viem";
1✔
10
import { useWaitForTransactionReceipt } from "wagmi";
1✔
11
import ApplicationAutocomplete from "./ApplicationAutocomplete";
1✔
12
import { TransactionFormSuccessData } from "./DepositFormTypes";
13
import { TransactionProgress } from "./TransactionProgress";
1✔
14
import { transactionState } from "./TransactionState";
1✔
15
import { Application, RollupVersion } from "./commons/interfaces";
16
import useUndeployedApplication from "./hooks/useUndeployedApplication";
1✔
17

18
export interface AddressRelayFormProps {
19
    applications: Application[];
20
    isLoadingApplications: boolean;
21
    onSearchApplications: (
22
        appAddress: string,
23
        rollupVersion?: RollupVersion,
24
    ) => void;
25
    onSuccess: (receipt: TransactionFormSuccessData) => void;
26
}
27

28
export const AddressRelayForm: FC<AddressRelayFormProps> = (props) => {
1✔
29
    const {
21✔
30
        applications,
21✔
31
        isLoadingApplications,
21✔
32
        onSearchApplications,
21✔
33
        onSuccess,
21✔
34
    } = props;
21✔
35
    const form = useForm({
21✔
36
        validateInputOnChange: true,
21✔
37
        initialValues: {
21✔
38
            application: "",
21✔
39
        },
21✔
40
        validate: {
21✔
41
            application: (value) =>
21✔
42
                value !== "" && isAddress(value)
28✔
43
                    ? null
9✔
44
                    : "Invalid application address",
19✔
45
        },
21✔
46
        transformValues: (values) => ({
21✔
47
            address: isAddress(values.application)
21✔
48
                ? getAddress(values.application)
5✔
49
                : zeroAddress,
16✔
50
        }),
21✔
51
    });
21✔
52
    const { address } = form.getTransformedValues();
21✔
53
    const prepare = useSimulateDAppAddressRelayRelayDAppAddress({
21✔
54
        args: [address],
21✔
55
        query: {
21✔
56
            enabled: address !== zeroAddress,
21✔
57
        },
21✔
58
    });
21✔
59

60
    const execute = useWriteDAppAddressRelayRelayDAppAddress();
21✔
61
    const wait = useWaitForTransactionReceipt({
21✔
62
        hash: execute.data,
21✔
63
    });
21✔
64

65
    const { loading, disabled } = transactionState(
21✔
66
        prepare,
21✔
67
        execute,
21✔
68
        wait,
21✔
69
        true,
21✔
70
    );
21✔
71
    const canSubmit = form.isValid();
21✔
72
    const addressList = applications.map((a) => a.address);
21✔
73
    const isUndeployedApp = useUndeployedApplication(address, addressList);
21✔
74

75
    useEffect(() => {
21✔
76
        onSearchApplications("", "v1");
11✔
77
        return () => onSearchApplications("");
11✔
78
    }, []);
21✔
79

80
    useEffect(() => {
21✔
81
        if (wait.isSuccess) {
21✔
82
            onSuccess({ receipt: wait.data, type: "ADDRESS-RELAY" });
2✔
83
            form.reset();
2✔
84
            execute.reset();
2✔
85
        }
2✔
86
    }, [wait, form, execute, onSuccess]);
21✔
87

88
    return (
21✔
89
        <form data-testid="address-relay-form">
21✔
90
            <Stack>
21✔
91
                <ApplicationAutocomplete
21✔
92
                    label="Application"
21✔
93
                    data-testid="application"
21✔
94
                    description="The application address to relay."
21✔
95
                    placeholder="0x"
21✔
96
                    applications={applications}
21✔
97
                    withAsterisk
21✔
98
                    rightSection={
21✔
99
                        (prepare.isLoading || isLoadingApplications) && (
21!
100
                            <Loader size="xs" />
×
101
                        )
102
                    }
103
                    {...form.getInputProps("application")}
21✔
104
                    error={
21✔
105
                        form.errors.application ||
21✔
106
                        (prepare.error as BaseError)?.shortMessage
18!
107
                    }
108
                    onChange={(nextValue) => {
21✔
109
                        form.setFieldValue("application", nextValue);
7✔
110
                        onSearchApplications(nextValue, "v1");
7✔
111
                    }}
7✔
112
                    onApplicationSelected={(app) => {
21✔
NEW
113
                        form.setFieldValue("application", app.address);
×
NEW
114
                        onSearchApplications(app.address, "v1");
×
UNCOV
115
                    }}
×
116
                />
21✔
117

118
                {!form.errors.application && isUndeployedApp && (
21✔
119
                    <Alert
1✔
120
                        variant="light"
1✔
121
                        color="yellow"
1✔
122
                        icon={<TbAlertCircle />}
1✔
123
                    >
1✔
124
                        This is an undeployed application.
125
                    </Alert>
1✔
126
                )}
127

128
                <Collapse in={!execute.isIdle || execute.isError}>
21✔
129
                    <TransactionProgress
21✔
130
                        prepare={prepare}
21✔
131
                        execute={execute}
21✔
132
                        wait={wait}
21✔
133
                        defaultErrorMessage={execute.error?.message}
21!
134
                    />
21✔
135
                </Collapse>
21✔
136

137
                <Group justify="right">
21✔
138
                    <Button
21✔
139
                        variant="filled"
21✔
140
                        disabled={disabled || !canSubmit}
21✔
141
                        leftSection={<TbCheck />}
21✔
142
                        loading={loading}
21✔
143
                        onClick={() =>
21✔
144
                            execute.writeContract(prepare.data!.request)
1✔
145
                        }
146
                    >
21✔
147
                        Send
148
                    </Button>
21✔
149
                </Group>
21✔
150
            </Stack>
21✔
151
        </form>
21✔
152
    );
153
};
21✔
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

© 2026 Coveralls, Inc