integrate get_evm_rotation_metadata runtime call

Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
Uncle Stretch 2026-11-14 16:08:36 +03:00
parent e19c856403
commit 096256794f
Signed by: str3tch
GPG Key ID: 84F3190747EE79AA
6 changed files with 515 additions and 412 deletions

View File

@ -3,7 +3,7 @@
"descriptorPath": ".papi\\descriptors",
"entries": {
"casper": {
"metadata": "metadatas/casper_runtime.scale"
"metadata": "casper_runtime.scale"
}
}
}

View File

@ -1,7 +1,7 @@
{
"name": "ghost-dao-interface",
"private": true,
"version": "0.8.14",
"version": "0.8.15",
"type": "module",
"scripts": {
"dev": "vite",

View File

@ -6,7 +6,6 @@ import { keccak256, hexToBytes, getAddress, toHex } from 'viem';
import {
Box,
Divider,
Link,
CircularProgress,
Container,
Typography,
@ -22,23 +21,16 @@ import {
} from "@mui/material";
import SearchIcon from '@mui/icons-material/Search';
import CloseIcon from '@mui/icons-material/Close';
import Chip from "../../components/Chip/Chip";
import Modal from "../../components/Modal/Modal";
import Paper from "../../components/Paper/Paper";
import Metric from "../../components/Metric/Metric";
import { Tab, Tabs } from "../../components/Tabs/Tabs";
import DataRow from "../../components/DataRow/DataRow";
import PageTitle from "../../components/PageTitle/PageTitle";
import GhostStyledIcon from "../../components/Icon/GhostIcon";
import TokenStack from "../../components/TokenStack/TokenStack";
import MetricCollection from "../../components/Metric/MetricCollection";
import { PrimaryButton, TertiaryButton } from "../../components/Button";
import LinearProgressBar from "../../components/Progress/LinearProgressBar";
import { useTotalReserves, useCapturedPriceSnapshots } from "../../hooks/treasury";
import { useCurrentGasPrice, useIsTransactionExecuted } from "../../hooks/staking";
import { useCurrentGasPrice } from "../../hooks/staking";
import { useFtsoPrice, useReservePrice } from "../../hooks/prices";
import { useTokenSymbol } from "../../hooks/tokens";
import { useUniswapV2Pair } from "../../hooks/uniswapv2";
@ -49,412 +41,17 @@ import { formatCurrency, formatNumber, shorten } from "../../helpers";
import { DecimalBigNumber } from "../../helpers/DecimalBigNumber";
import { UNISWAP_V2_FACTORY } from "../../constants/addresses";
const SELECTABLE_OPTIONS = ["All Exoduses", "Rotations", "Governance", "Bridge-Out"];
import { ExodusVerifyModal } from "./ExodusModal";
import ExodusStatusCard from "./ExodusStatusCard";
import ExodusList from "./ExodusList";
const SELECTABLE_OPTIONS = ["All Exoduses", "Rotations", "Governance", "Bridge-Out"];
const KEY_ROTATION = "Key Rotation";
const GAS_USED = {
[KEY_ROTATION]: 300000n,
}
const ExodusStatusCard = ({ progressPercent, executionDiscount, currentGasPrice, maxGasPrice }) => {
const theme = useTheme();
return (
<Box mt="30px" sx={{ mb: { xs: "0px", md: "-30px" }}}>
<Box display="flex" justifyContent="space-between" alignItems="center" mt="2px">
<Box display="flex" alignItems="center" gap="5px">
<Typography variant="caption" fontWeight="bold">Execution Discount: </Typography>
<Typography variant="caption" fontWeight="bold" sx={{
color: Number(executionDiscount) > 0
? theme.colors.feedback.success
: theme.colors.feedback.error
}}>
{formatNumber(executionDiscount, 2)}%
</Typography>
</Box>
<Typography variant="caption">
<Box display="flex" flexDirection="row" gap="5px">
<Typography variant="caption" sx={{ fontWeight: "700" }}>Gas Price:</Typography>
<Typography variant="caption">{`${formatNumber(currentGasPrice, 5)} / ${formatNumber(maxGasPrice, 5)} gwei`}</Typography>
</Box>
</Typography>
</Box>
<LinearProgressBar
variant={"determinate"}
value={Math.max(100, Number(currentGasPrice.div(maxGasPrice).toString()) * 100)}
height={6}
barColor={theme.colors.feedback.success}
/>
</Box>
);
};
const ExodusItem = ({
item,
chainId,
gasPrice,
ftsoSymbol,
nativeMetadata,
setVerifiedItem,
isSmallScreen,
currentTwapPrice
}) => {
const theme = useTheme();
const isVerySmallScreen = useMediaQuery("(max-width: 450px)");
const {
isTransactionExecuted,
isTransactionExecutedLoading
} = useIsTransactionExecuted(chainId, item.data.at(0)?.session);
const chipStatus = useMemo(() => {
const width = isVerySmallScreen ? "21px" : "100px";
if (isTransactionExecuted && !isTransactionExecutedLoading) {
return <Chip sx={{ width: width }} label={isVerySmallScreen ? "" : "Executed"} template={"gray"} />
}
return <Chip sx={{ width: width }} label={isVerySmallScreen ? "" : "Ready"} template={"success"} />
}, [isTransactionExecutedLoading, isTransactionExecuted]);
if (isSmallScreen || isVerySmallScreen) {
return (
<>
<Box display="flex" flexDirection="column" gap="10px">
<Box
display="flex"
alignItems="center"
justifyContent="space-between"
flexDirection={isVerySmallScreen ? "row" : "row"}
>
<Box display="flex" gap="20px" p="10px 0">
<TokenStack chainTokenNames={[nativeMetadata.symbol]} tokens={[ftsoSymbol]} />
<Box display="flex" flexDirection="column">
<Typography>{item.type}</Typography>
<Link
href={`${nativeMetadata.url}`}
target="_blank"
rel="noopener noreferrer"
>
<Typography>{"Something here"}</Typography>
</Link>
</Box>
</Box>
<Box display="flex" flexDirection="column" alignItems="flex-end">
{chipStatus}
</Box>
</Box>
<Box width="100%" display="flex" flexDirection="row" justifyContent="space-between">
<Box display="flex" flexDirection="column">
<Typography>{nativeMetadata.symbol} Cost</Typography>
<Typography>{
formatCurrency(
currentTwapPrice(gasPrice * GAS_USED[item.type]).toString(),
5,
ftsoSymbol
)
}</Typography>
</Box>
<Box display="flex" flexDirection="column">
<Typography>Reward</Typography>
<Typography>
{formatCurrency(
new DecimalBigNumber(gasPrice * GAS_USED[item.type], 18),
5,
nativeMetadata.symbol
)}
</Typography>
</Box>
</Box>
<Box display="flex" flexDirection="row" gap="20px">
<TertiaryButton fullWidth onClick={setVerifiedItem}>Verify</TertiaryButton>
</Box>
</Box>
</>
)
}
return (
<TableRow>
<TableCell sx={{ padding: "10px 0" }}>
<Box display="flex" alignItems="center">
<TokenStack chainTokenNames={[nativeMetadata.symbol]} tokens={[ftsoSymbol]} />
<Box ml="10px" display="flex" flexDirection="column" alignItems="flex-start">
<Typography>{item.type}</Typography>
<Link
href={`${nativeMetadata.url}`}
target="_blank"
rel="noopener noreferrer"
>
<Typography>{"Something here"}</Typography>
</Link>
</Box>
</Box>
</TableCell>
<TableCell align="center" sx={{ padding: "10px 0" }}>
{chipStatus}
</TableCell>
<TableCell align="center" sx={{ padding: "10px 0" }}>
{formatCurrency(
new DecimalBigNumber(gasPrice * GAS_USED[item.type], 18),
5,
nativeMetadata.symbol
)}
</TableCell>
<TableCell align="center" sx={{ padding: "10px 0" }}>
<Typography>{
formatCurrency(
currentTwapPrice(gasPrice * GAS_USED[item.type]).toString(),
5,
ftsoSymbol
)
}</Typography>
</TableCell>
<TableCell sx={{ padding: "10px 0" }}>
<Box p="0 30px" display="flex" justifyContent="center" alignItems="center">
<TertiaryButton
fullWidth
disabled={isTransactionExecuted || isTransactionExecutedLoading}
onClick={() => setVerifiedItem({ dkgIndex: item.dkgIndex, type: item.type })}
>
Verify
</TertiaryButton>
</Box>
</TableCell>
</TableRow>
)
}
const ExodusList = ({
chainId,
nativeMetadata,
setVerifiedItem,
ftsoSymbol,
gasPrice,
currentTwapPrice,
signedExodusRotations,
signedExodusRotationsLoading,
}) => {
const isSmallScreen = useMediaQuery("(max-width: 900px)");
const chainedExoduses = useMemo(() => {
let chain = [];
if (Array.isArray(signedExodusRotations)) chain = [...chain, ...signedExodusRotations];
return chain;
}, [signedExodusRotations]);
if (signedExodusRotationsLoading) {
return (
<Box my="20px" display="flex" flexDirection="column" justifyContent="center" alignItems="center" gap="50px">
<CircularProgress color="primary" />
<Typography>Loading Signed Rotations...</Typography>
</Box>
)
}
if (isSmallScreen) {
return (
<Box display="flex" flexDirection="column" gap="50px">
{chainedExoduses.map((item, i) => {
return (
<ExodusItem
key={i}
item={item}
chainId={chainId}
gasPrice={gasPrice}
ftsoSymbol={ftsoSymbol}
setVerifiedItem={setVerifiedItem}
currentTwapPrice={currentTwapPrice}
nativeMetadata={nativeMetadata}
isSmallScreen={isSmallScreen}
/>
)
})}
</Box>
)
} else {
return (
<TableContainer>
<Table aria-label="Available bonds" style={{ tableLayout: "fixed" }}>
<TableHead>
<TableRow>
<TableCell style={{ padding: "8px 0" }}>Exodus</TableCell>
<TableCell style={{ padding: "8px 0" }} align="center">Status</TableCell>
<TableCell style={{ padding: "8px 0" }} align="center">{nativeMetadata.symbol} Cost</TableCell>
<TableCell style={{ padding: "8px 0" }} align="center">Reward</TableCell>
<TableCell style={{ padding: "8px 0" }}></TableCell>
</TableRow>
</TableHead>
<TableBody>
{chainedExoduses.map((item, i) => {
return (
<ExodusItem
key={i}
item={item}
chainId={chainId}
gasPrice={gasPrice}
ftsoSymbol={ftsoSymbol}
setVerifiedItem={setVerifiedItem}
nativeMetadata={nativeMetadata}
currentTwapPrice={currentTwapPrice}
isSmallScreen={isSmallScreen}
/>
)
})}
</TableBody>
</Table>
</TableContainer>
)
}
}
const ExodusVerify = ({
chainId,
isOpen,
onClose,
nativeMetadata,
address,
casperApi,
item,
ftsoSymbol,
gasPrice,
currentTwapPrice,
}) => {
const [isPending, setIsPending] = useState(false);
const { data: signedExodusRotation } = useSWR(
casperApi && item ? ['signedExodusRotations', casperApi, item] : null,
async ([_, api, it]) => api.query.GhostExodus.ExodusSignedRotations.getValue(it.dkgIndex, { type: "Evm" }),
);
const upcomingGroupKey = useMemo(() => {
if (!signedExodusRotation) return null;
const publicKey = signedExodusRotation?.at(1)["r#type"].value.public_key;
if (!publicKey) return null;
const cleanHex = publicKey.startsWith('0x04') && publicKey.length === 130
? `0x${publicKey.slice(4)}`
: publicKey.startsWith('0x')
? publicKey
: `0x${publicKey}`;
const hash = keccak256(cleanHex);
return getAddress(`0x${hash.slice(-40)}`);
}, [signedExodusRotation]);
const signedMessageMetadata = useMemo(() => {
if (!signedExodusRotation) return null;
const nonce = signedExodusRotation?.at(1).nonce;
const signature = signedExodusRotation?.at(1).signature;
return {
nonce: nonce ? toHex(nonce) : null,
signature: signature ? toHex(signature) : null,
message: "0xdeadbeef",
};
}, [signedExodusRotation])
return (
<Modal
maxWidth="426px"
minHeight="200px"
open={isOpen}
headerContent={<Typography variant="h4">Verify {item?.type}</Typography>}
onClose={!isPending && onClose}
topRight={
<GhostStyledIcon
viewBox="0 0 23 23"
component={CloseIcon}
/>
}
>
<Box display="flex" flexDirection="column">
<Box mb="15px" display="flex" flexDirection="column" gap="1px" sx={{ "& .DataRow-root": { margin: "0 !important" } }}>
<DataRow
title={<Typography variant="caption">New Group Key</Typography>}
tooltip="Some cool description here."
balance={<Link
href={`${nativeMetadata.url}/address/${upcomingGroupKey}`}
target="_blank"
rel="noopener noreferrer"
>
<Typography variant="caption">{
upcomingGroupKey ? shorten(upcomingGroupKey, 12, -8) : ""
}</Typography>
</Link>}
/>
<DataRow
title={<Typography variant="caption">Verification Reward</Typography>}
tooltip="Some cool description here."
balance={<Typography variant="caption">{
formatCurrency(
currentTwapPrice(
(gasPrice ? gasPrice : 0n) *
(GAS_USED[item?.type] ? GAS_USED[item?.type] : 0n)
).toString(),
5,
ftsoSymbol
)
}</Typography>}
/>
<Divider sx={{ my: "15px", width: "100%" }} />
<DataRow
title={<Typography variant="caption">Nonce</Typography>}
tooltip="Some cool description here."
balance={<Typography variant="caption">
{signedMessageMetadata?.nonce ? shorten(signedMessageMetadata.nonce, 12, -10) : ""}
</Typography>}
/>
<DataRow
title={<Typography variant="caption">Signture</Typography>}
tooltip="Some cool description here."
balance={<Typography variant="caption">
{signedMessageMetadata?.signature ? shorten(signedMessageMetadata.signature, 12, -10) : ""}
</Typography>}
/>
<DataRow
title={<Typography variant="caption">Signed Message</Typography>}
tooltip="Some cool description here."
balance={<Typography variant="caption">
{signedMessageMetadata?.message ? signedMessageMetadata.message : ""}
</Typography>}
/>
</Box>
<PrimaryButton
fullWidth
onClick={() => {
alert("not ready for now");
onClose();
}}
>
Verify
</PrimaryButton>
</Box>
</Modal>
)
}
const Exodus = ({ chainId, address, config }) => {
const theme = useTheme();
@ -527,7 +124,7 @@ const Exodus = ({ chainId, address, config }) => {
const promises = Array.from({ length }, (_, index) => start + index).map(index =>
api.query.GhostExodus.ExodusSignedRotations.getValue(index, { type: "Evm" })
.then(data => ({ dkgIndex: index, type: KEY_ROTATION, data }))
.then(data => ({ dkgIndex: index, type: KEY_ROTATION, gasUsed: GAS_USED[KEY_ROTATION], data }))
);
return Promise.all(promises);
@ -546,7 +143,7 @@ const Exodus = ({ chainId, address, config }) => {
paddingRight: isSmallScreen || isVerySmallScreen ? "0" : "3.3rem",
}}
>
<ExodusVerify
<ExodusVerifyModal
chainId={chainId}
address={address}
isOpen={!!verifiedItem}
@ -557,6 +154,7 @@ const Exodus = ({ chainId, address, config }) => {
gasPrice={gasPrice}
currentTwapPrice={currentTwapPrice}
onClose={() => setVerifiedItem(null)}
gasUsed={GAS_USED[verifiedItem?.type]}
/>
<Box mt="15px" display="flex" flexDirection="column" justifyContent="space-between" alignItems="center">

View File

@ -0,0 +1,270 @@
import { useMemo } from "react";
import {
Box,
Link,
CircularProgress,
Container,
Typography,
TableContainer,
TableCell,
Table,
TableHead,
TableRow,
TableBody,
useMediaQuery,
useTheme,
} from "@mui/material";
import Chip from "../../components/Chip/Chip";
import { TertiaryButton } from "../../components/Button";
import TokenStack from "../../components/TokenStack/TokenStack";
import { useIsTransactionExecuted } from "../../hooks/staking";
import { formatCurrency } from "../../helpers";
import { DecimalBigNumber } from "../../helpers/DecimalBigNumber";
const ExodusItem = ({
item,
chainId,
gasPrice,
ftsoSymbol,
nativeMetadata,
setVerifiedItem,
isSmallScreen,
currentTwapPrice
}) => {
const theme = useTheme();
const isVerySmallScreen = useMediaQuery("(max-width: 450px)");
const {
isTransactionExecuted,
isTransactionExecutedLoading
} = useIsTransactionExecuted(chainId, item.data.at(0)?.session);
const chipStatus = useMemo(() => {
const width = isVerySmallScreen ? "21px" : "100px";
if (isTransactionExecuted && !isTransactionExecutedLoading) {
return <Chip sx={{ width: width }} label={isVerySmallScreen ? "" : "Executed"} template={"gray"} />
}
return <Chip sx={{ width: width }} label={isVerySmallScreen ? "" : "Ready"} template={"success"} />
}, [isTransactionExecutedLoading, isTransactionExecuted]);
if (isSmallScreen || isVerySmallScreen) {
return (
<>
<Box display="flex" flexDirection="column" gap="10px">
<Box
display="flex"
alignItems="center"
justifyContent="space-between"
flexDirection={isVerySmallScreen ? "row" : "row"}
>
<Box display="flex" gap="20px" p="10px 0">
<TokenStack chainTokenNames={[nativeMetadata.symbol]} tokens={[ftsoSymbol]} />
<Box display="flex" flexDirection="column">
<Typography>{item.type}</Typography>
<Link
href={`${nativeMetadata.url}`}
target="_blank"
rel="noopener noreferrer"
>
<Typography>{"Something here"}</Typography>
</Link>
</Box>
</Box>
<Box display="flex" flexDirection="column" alignItems="flex-end">
{chipStatus}
</Box>
</Box>
<Box width="100%" display="flex" flexDirection="row" justifyContent="space-between">
<Box display="flex" flexDirection="column">
<Typography>{nativeMetadata.symbol} Cost</Typography>
<Typography>{
formatCurrency(
currentTwapPrice(gasPrice * item.gasUsed).toString(),
5,
ftsoSymbol
)
}</Typography>
</Box>
<Box display="flex" flexDirection="column">
<Typography>Reward</Typography>
<Typography>
{formatCurrency(
new DecimalBigNumber(gasPrice * item.gasUsed, 18),
5,
nativeMetadata.symbol
)}
</Typography>
</Box>
</Box>
<Box display="flex" flexDirection="row" gap="20px">
<TertiaryButton
fullWidth
disabled={isTransactionExecuted || isTransactionExecutedLoading}
onClick={() => setVerifiedItem({
exodusSession: item.data.at(0).session,
dkgIndex: item.dkgIndex,
type: item.type
})}
>
Verify
</TertiaryButton>
</Box>
</Box>
</>
)
}
return (
<TableRow>
<TableCell sx={{ padding: "10px 0" }}>
<Box display="flex" alignItems="center">
<TokenStack chainTokenNames={[nativeMetadata.symbol]} tokens={[ftsoSymbol]} />
<Box ml="10px" display="flex" flexDirection="column" alignItems="flex-start">
<Typography>{item.type}</Typography>
<Link
href={`${nativeMetadata.url}`}
target="_blank"
rel="noopener noreferrer"
>
<Typography>{"Something here"}</Typography>
</Link>
</Box>
</Box>
</TableCell>
<TableCell align="center" sx={{ padding: "10px 0" }}>
{chipStatus}
</TableCell>
<TableCell align="center" sx={{ padding: "10px 0" }}>
{formatCurrency(
new DecimalBigNumber(gasPrice * item.gasUsed, 18),
5,
nativeMetadata.symbol
)}
</TableCell>
<TableCell align="center" sx={{ padding: "10px 0" }}>
<Typography>{
formatCurrency(
currentTwapPrice(gasPrice * item.gasUsed).toString(),
5,
ftsoSymbol
)
}</Typography>
</TableCell>
<TableCell sx={{ padding: "10px 0" }}>
<Box p="0 30px" display="flex" justifyContent="center" alignItems="center">
<TertiaryButton
fullWidth
disabled={isTransactionExecuted || isTransactionExecutedLoading}
onClick={() => setVerifiedItem({
exodusSession: item.data.at(0).session,
dkgIndex: item.dkgIndex,
type: item.type
})}
>
Verify
</TertiaryButton>
</Box>
</TableCell>
</TableRow>
)
}
const ExodusList = ({
chainId,
nativeMetadata,
setVerifiedItem,
ftsoSymbol,
gasPrice,
currentTwapPrice,
signedExodusRotations,
signedExodusRotationsLoading,
}) => {
const isSmallScreen = useMediaQuery("(max-width: 900px)");
const chainedExoduses = useMemo(() => {
let chain = [];
if (Array.isArray(signedExodusRotations)) chain = [...chain, ...signedExodusRotations];
return chain;
}, [signedExodusRotations]);
if (signedExodusRotationsLoading) {
return (
<Box my="20px" display="flex" flexDirection="column" justifyContent="center" alignItems="center" gap="50px">
<CircularProgress color="primary" />
<Typography>Loading Signed Rotations...</Typography>
</Box>
)
}
if (isSmallScreen) {
return (
<Box display="flex" flexDirection="column" gap="50px">
{chainedExoduses.map((item, i) => {
return (
<ExodusItem
key={i}
item={item}
chainId={chainId}
gasPrice={gasPrice}
ftsoSymbol={ftsoSymbol}
setVerifiedItem={setVerifiedItem}
currentTwapPrice={currentTwapPrice}
nativeMetadata={nativeMetadata}
isSmallScreen={isSmallScreen}
/>
)
})}
</Box>
)
} else {
return (
<TableContainer>
<Table aria-label="Available bonds" style={{ tableLayout: "fixed" }}>
<TableHead>
<TableRow>
<TableCell style={{ padding: "8px 0" }}>Exodus</TableCell>
<TableCell style={{ padding: "8px 0" }} align="center">Status</TableCell>
<TableCell style={{ padding: "8px 0" }} align="center">{nativeMetadata.symbol} Cost</TableCell>
<TableCell style={{ padding: "8px 0" }} align="center">Reward</TableCell>
<TableCell style={{ padding: "8px 0" }}></TableCell>
</TableRow>
</TableHead>
<TableBody>
{chainedExoduses.map((item, i) => {
return (
<ExodusItem
key={i}
item={item}
chainId={chainId}
gasPrice={gasPrice}
ftsoSymbol={ftsoSymbol}
setVerifiedItem={setVerifiedItem}
nativeMetadata={nativeMetadata}
currentTwapPrice={currentTwapPrice}
isSmallScreen={isSmallScreen}
/>
)
})}
</TableBody>
</Table>
</TableContainer>
)
}
}
export default ExodusList;

View File

@ -0,0 +1,196 @@
import useSWR from "swr";
import { useState, useMemo } from "react";
import { Box, Divider, Link, Skeleton, Typography } from "@mui/material";
import { keccak256, hexToBytes, getAddress, toHex } from 'viem';
import CloseIcon from '@mui/icons-material/Close';
import CheckIcon from '@mui/icons-material/Check';
import ContentPasteIcon from '@mui/icons-material/ContentPaste';
import Modal from "../../components/Modal/Modal";
import DataRow from "../../components/DataRow/DataRow";
import GhostStyledIcon from "../../components/Icon/GhostIcon";
import { PrimaryButton } from "../../components/Button";
import { formatCurrency, shorten } from "../../helpers";
import { useUnstableProvider } from "../../hooks/ghost";
export const ExodusVerifyModal = ({
chainId,
isOpen,
onClose,
nativeMetadata,
address,
casperApi,
item,
ftsoSymbol,
gasPrice,
gasUsed,
currentTwapPrice,
}) => {
const [isPending, setIsPending] = useState(false);
const [copiedIndex, setCopiedIndex] = useState(null);
const { client } = useUnstableProvider();
const copyToClipboard = (text, index) => {
navigator.clipboard.writeText(text).then(() => {
setCopiedIndex(index);
setTimeout(() => setCopiedIndex(null) , 800);
});
};
const { data: signedExodusRotation } = useSWR(
casperApi && item ? ['signedExodusRotations', casperApi, item] : null,
async ([_, api, it]) => api.query.GhostExodus.ExodusSignedRotations.getValue(it.dkgIndex, { type: "Evm" }),
);
const { data: evmMessageMetadata, isLoading: evmMessageMetadataLoading } = useSWR(
client && item ? ['evmMessage', client, item] : null,
async ([_, client, it]) =>
client.getUnsafeApi().apis.ExodusApi.get_evm_rotation_metadata(
BigInt(it.dkgIndex),
{ type: "Evm" }
)
);
const upcomingGroupKey = useMemo(() => {
if (!signedExodusRotation) return null;
const publicKey = signedExodusRotation?.at(1)["r#type"].value.public_key;
if (!publicKey) return null;
const cleanHex = publicKey.startsWith('0x04') && publicKey.length === 130
? `0x${publicKey.slice(4)}`
: publicKey.startsWith('0x')
? publicKey
: `0x${publicKey}`;
const hash = keccak256(cleanHex);
return getAddress(`0x${hash.slice(-40)}`);
}, [signedExodusRotation]);
return (
<Modal
maxWidth="426px"
minHeight="200px"
open={isOpen}
headerContent={<Typography variant="h4">Verify {item ? item.type : ""}</Typography>}
onClose={!isPending && onClose}
topRight={
<GhostStyledIcon
viewBox="0 0 23 23"
component={CloseIcon}
onClick={onClose}
/>
}
>
<Box display="flex" flexDirection="column">
<Box mb="15px" display="flex" flexDirection="column" gap="1px" sx={{ "& .DataRow-root": { margin: "0 !important" } }}>
<DataRow
title={<Typography variant="caption">New Group Key</Typography>}
tooltip="Some cool description here."
balance={<Link
href={`${nativeMetadata.url}/address/${upcomingGroupKey}`}
target="_blank"
rel="noopener noreferrer"
>
<Typography variant="caption">{
upcomingGroupKey ? shorten(upcomingGroupKey, 12, -8) : ""
}</Typography>
</Link>}
/>
<DataRow
title={<Typography variant="caption">Verification Reward</Typography>}
tooltip="Some cool description here."
balance={<Typography variant="caption">{
formatCurrency(
currentTwapPrice((gasPrice ? gasPrice : 0n) * (gasUsed ? gasUsed : 0n)).toString(),
5,
ftsoSymbol
)
}</Typography>}
/>
<Divider sx={{ my: "15px", width: "100%" }} />
<DataRow
title={<Typography variant="caption">Raw Message</Typography>}
tooltip="Some cool description here."
balance={evmMessageMetadata?.at(0)
? <Link
style={{ display: "flex", flexDirection: "row", justifyContent: "center", alignItems: "center" }}
onClick={() => copyToClipboard(toHex(evmMessageMetadata.at(0)), 0)}
>
<Typography variant="caption">
{shorten(toHex(evmMessageMetadata.at(0)), 12, -10)}
</Typography>
<GhostStyledIcon
sx={{ marginLeft: "5px", width: "12px", height: "12px" }}
viewBox="0 0 25 25"
component={copiedIndex === 0 ? CheckIcon : ContentPasteIcon}
/>
</Link>
: <Skeleton width="185px" />
}
/>
<DataRow
title={<Typography variant="caption">Nonce</Typography>}
tooltip="Some cool description here."
balance={evmMessageMetadata?.at(1)
? <Link
style={{ display: "flex", flexDirection: "row", justifyContent: "center", alignItems: "center" }}
onClick={() => copyToClipboard(toHex(evmMessageMetadata.at(1)), 1)}
>
<Typography variant="caption">
{shorten(toHex(evmMessageMetadata.at(1)), 12, -10)}
</Typography>
<GhostStyledIcon
sx={{ marginLeft: "5px", width: "12px", height: "12px" }}
viewBox="0 0 25 25"
component={copiedIndex === 1 ? CheckIcon : ContentPasteIcon}
/>
</Link>
: <Skeleton width="185px" />
}
/>
<DataRow
title={<Typography variant="caption">Signture</Typography>}
tooltip="Some cool description here."
balance={evmMessageMetadata?.at(2)
? <Link
style={{ display: "flex", flexDirection: "row", justifyContent: "center", alignItems: "center" }}
onClick={() => copyToClipboard(toHex(evmMessageMetadata.at(2)), 2)}
>
<Typography variant="caption">
{shorten(toHex(evmMessageMetadata.at(2)), 12, -10)}
</Typography>
<GhostStyledIcon
sx={{ marginLeft: "5px", width: "12px", height: "12px" }}
viewBox="0 0 25 25"
component={copiedIndex === 2 ? CheckIcon : ContentPasteIcon}
/>
</Link>
: <Skeleton width="185px" />
}
/>
</Box>
<PrimaryButton
fullWidth
disabled={evmMessageMetadataLoading || !evmMessageMetadata}
onClick={() => {
alert("not ready for now");
onClose();
}}
>
Verify
</PrimaryButton>
</Box>
</Modal>
)
}

View File

@ -0,0 +1,39 @@
import { Box, Typography, useTheme } from "@mui/material";
import { formatNumber } from "../../helpers";
import LinearProgressBar from "../../components/Progress/LinearProgressBar";
const ExodusStatusCard = ({ progressPercent, executionDiscount, currentGasPrice, maxGasPrice }) => {
const theme = useTheme();
return (
<Box mt="30px" sx={{ mb: { xs: "0px", md: "-30px" }}}>
<Box display="flex" justifyContent="space-between" alignItems="center" mt="2px">
<Box display="flex" alignItems="center" gap="5px">
<Typography variant="caption" fontWeight="bold">Execution Discount: </Typography>
<Typography variant="caption" fontWeight="bold" sx={{
color: Number(executionDiscount) > 0
? theme.colors.feedback.success
: theme.colors.feedback.error
}}>
{formatNumber(executionDiscount, 2)}%
</Typography>
</Box>
<Typography variant="caption">
<Box display="flex" flexDirection="row" gap="5px">
<Typography variant="caption" sx={{ fontWeight: "700" }}>Gas Price:</Typography>
<Typography variant="caption">{`${formatNumber(currentGasPrice, 5)} / ${formatNumber(maxGasPrice, 5)} gwei`}</Typography>
</Box>
</Typography>
</Box>
<LinearProgressBar
variant={"determinate"}
value={Math.max(100, Number(currentGasPrice.div(maxGasPrice).toString()) * 100)}
height={6}
barColor={theme.colors.feedback.success}
/>
</Box>
);
};
export default ExodusStatusCard;