kopia lustrzana https://github.com/bugout-dev/moonstream
fixed bug when transaction is undefined
rodzic
aaee2e2e67
commit
e9ac313c82
|
@ -49,11 +49,12 @@ const Entry = () => {
|
|||
data: entry,
|
||||
isFetchedAfterMount,
|
||||
isLoading,
|
||||
isFetching, //If transaction.tx is undefined, will not fetch
|
||||
isError,
|
||||
error,
|
||||
} = useTxInfo({ tx: ui.currentTransaction });
|
||||
|
||||
if (isError) {
|
||||
setInterval(() => console.log(entry, isFetchedAfterMount, isLoading, isError, error), 100)
|
||||
if (!isFetching) {
|
||||
return callReroute();
|
||||
}
|
||||
if (isError && error.response.status === 404) return <FourOFour />;
|
||||
|
|
|
@ -10,7 +10,7 @@ import {
|
|||
VStack,
|
||||
} from "@chakra-ui/react";
|
||||
import { Table, Thead, Tbody, Tr, Th, Td } from "@chakra-ui/react";
|
||||
|
||||
const toEth = (wei) => { return wei / Math.pow(10, 18) }
|
||||
const TxABI = (props) => {
|
||||
const byteCode = props.byteCode;
|
||||
const abi = props.abi;
|
||||
|
@ -58,17 +58,19 @@ const TxInfo = (props) => {
|
|||
<StatGroup>
|
||||
<Stat>
|
||||
<StatLabel>Value</StatLabel>
|
||||
<StatNumber>{transaction.tx.value}</StatNumber>
|
||||
<StatHelpText>amount of ETH to transfer in WEI</StatHelpText>
|
||||
<StatNumber>{transaction.tx.value} wei</StatNumber>
|
||||
<StatNumber>{toEth(transaction.tx.value)} eth</StatNumber>
|
||||
<StatHelpText>amount of ETH to transfer</StatHelpText>
|
||||
</Stat>
|
||||
<Stat>
|
||||
<StatLabel>Gas</StatLabel>
|
||||
<StatLabel>Gas limit</StatLabel>
|
||||
<StatNumber>{transaction.tx.gas}</StatNumber>
|
||||
<StatHelpText>gas unit used for transaction</StatHelpText>
|
||||
<StatHelpText>Maximum amount of gas </StatHelpText>
|
||||
<StatHelpText>provided for the transaction</StatHelpText>
|
||||
</Stat>
|
||||
<Stat>
|
||||
<StatLabel>Gas price</StatLabel>
|
||||
<StatNumber>{transaction.tx.gasPrice}</StatNumber>
|
||||
<StatNumber>{transaction.tx.gasPrice} wei</StatNumber>
|
||||
<StatHelpText>the fee the sender pays per unit of gas</StatHelpText>
|
||||
</Stat>
|
||||
</StatGroup>
|
||||
|
|
|
@ -10,13 +10,13 @@ const useTxInfo = (transaction) => {
|
|||
return response.data;
|
||||
};
|
||||
const { data, isLoading, isFetchedAfterMount, refetch, isError, error } =
|
||||
useQuery(["txinfo", transaction.tx.hash], getTxInfo, {
|
||||
useQuery(["txinfo", (transaction.tx && transaction.tx.hash)], getTxInfo, {
|
||||
...queryCacheProps,
|
||||
enabled: !!transaction.tx,
|
||||
onError: (error) => toast(error, "error"),
|
||||
});
|
||||
|
||||
return { data, isFetchedAfterMount, isLoading, refetch, isError, error };
|
||||
const isFetching = !!transaction.tx;
|
||||
return { data, isFetchedAfterMount, isLoading, refetch, isFetching, isError, error };
|
||||
};
|
||||
|
||||
export default useTxInfo;
|
||||
|
|
Ładowanie…
Reference in New Issue