dynamic gas price from EVM; fix executed transactions hook in the history list item
Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
parent
fc043af3e5
commit
a78b583be3
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "ghost-dao-interface",
|
"name": "ghost-dao-interface",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.8.26",
|
"version": "0.8.27",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import useSWR from "swr";
|
import useSWR from "swr";
|
||||||
import { useMemo, useState, useCallback } from "react";
|
import { useMemo, useState, useCallback, useEffect } from "react";
|
||||||
import { useGasPrice } from 'wagmi';
|
import { getGasPrice } from "@wagmi/core";
|
||||||
import { keccak256, hexToBytes, getAddress, toHex } from 'viem';
|
import { keccak256, hexToBytes, getAddress, toHex } from 'viem';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -62,10 +62,32 @@ const Exodus = ({ chainId, address, config }) => {
|
|||||||
const isSemiSmallScreen = useMediaQuery("(max-width: 850px)");
|
const isSemiSmallScreen = useMediaQuery("(max-width: 850px)");
|
||||||
const isVerySmallScreen = useMediaQuery("(max-width: 379px)");
|
const isVerySmallScreen = useMediaQuery("(max-width: 379px)");
|
||||||
|
|
||||||
|
const [gasPrice, setGasPrice] = useState(0n);
|
||||||
const [dkgHistory, setDkgHistory] = useState([]);
|
const [dkgHistory, setDkgHistory] = useState([]);
|
||||||
const [searchOpen, setSearchOpen] = useState(false);
|
const [searchOpen, setSearchOpen] = useState(false);
|
||||||
const [verifiedItem, setVerifiedItem] = useState(null);
|
const [verifiedItem, setVerifiedItem] = useState(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let isMounted = true;
|
||||||
|
|
||||||
|
const fetchBlock = async () => {
|
||||||
|
try {
|
||||||
|
const evmGasPrice = await getGasPrice(config, { chainId });
|
||||||
|
if (isMounted) setGasPrice(evmGasPrice);
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error fetching EVM gas price:', err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
fetchBlock();
|
||||||
|
const intervalId = setInterval(fetchBlock, 5000);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
isMounted = false;
|
||||||
|
clearInterval(intervalId);
|
||||||
|
};
|
||||||
|
}, [chainId, config]);
|
||||||
|
|
||||||
const { casperApi, client } = useUnstableProvider();
|
const { casperApi, client } = useUnstableProvider();
|
||||||
|
|
||||||
const nativeMetadata = useMemo(() => {
|
const nativeMetadata = useMemo(() => {
|
||||||
@ -77,11 +99,9 @@ const Exodus = ({ chainId, address, config }) => {
|
|||||||
}
|
}
|
||||||
}, [config]);
|
}, [config]);
|
||||||
|
|
||||||
const { data: gasPrice } = useGasPrice(chainId);
|
|
||||||
const { symbol: ftsoSymbol } = useTokenSymbol(chainId, "FTSO");
|
|
||||||
|
|
||||||
const ftsoPrice = useFtsoPrice(chainId);
|
const ftsoPrice = useFtsoPrice(chainId);
|
||||||
const reservePrice = useReservePrice(chainId);
|
const reservePrice = useReservePrice(chainId);
|
||||||
|
const { symbol: ftsoSymbol } = useTokenSymbol(chainId, "FTSO");
|
||||||
const { currentGasPrice, maxGasPrice } = useCurrentGasPrice(chainId);
|
const { currentGasPrice, maxGasPrice } = useCurrentGasPrice(chainId);
|
||||||
|
|
||||||
const { pairAddress } = useUniswapV2Pair(
|
const { pairAddress } = useUniswapV2Pair(
|
||||||
|
|||||||
@ -42,13 +42,17 @@ const ExodusItem = ({
|
|||||||
isTransactionExecuted,
|
isTransactionExecuted,
|
||||||
isTransactionExecutedLoading,
|
isTransactionExecutedLoading,
|
||||||
refetchTransactionExecuted
|
refetchTransactionExecuted
|
||||||
} = useIsTransactionExecuted(item.exodusContext.network_id, item.exodusContext.session);
|
} = useIsTransactionExecuted(Number(item.exodusContext.network_id), Number(item.exodusContext.session));
|
||||||
|
|
||||||
const chipStatus = useMemo(() => {
|
const chipStatus = useMemo(() => {
|
||||||
const width = isVerySmallScreen ? "21px" : "100px";
|
const width = isVerySmallScreen ? "21px" : "100px";
|
||||||
|
|
||||||
if (isTransactionExecuted && !isTransactionExecutedLoading) {
|
if (isTransactionExecuted && !isTransactionExecutedLoading) {
|
||||||
return <Chip sx={{ width: width }} label={isVerySmallScreen ? "" : "Executed"} template={"gray"} />
|
return <Chip
|
||||||
|
sx={{ width: width }}
|
||||||
|
template={"gray"}
|
||||||
|
label={isVerySmallScreen ? "" : isTransactionExecutedLoading ? "Checking..." : "Executed"}
|
||||||
|
/>
|
||||||
}
|
}
|
||||||
|
|
||||||
return <Chip sx={{ width: width }} label={isVerySmallScreen ? "" : "Ready"} template={"success"} />
|
return <Chip sx={{ width: width }} label={isVerySmallScreen ? "" : "Ready"} template={"success"} />
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user