kopia lustrzana https://github.com/bugout-dev/moonstream
Prettier formatting
rodzic
b20a95b0ac
commit
a6069b6c11
|
@ -30,12 +30,11 @@ const StreamEntry = ({ entry, filterCallback, filterConstants }) => {
|
|||
} else if (copyString) {
|
||||
onCopy();
|
||||
}
|
||||
|
||||
}, [copyString, onCopy, hasCopied, toast]);
|
||||
const handleViewClicked = (entryId) => {
|
||||
ui.setEntryId(entryId);
|
||||
ui.setEntriesViewMode("entry");
|
||||
useTxCashe.setCurrentTransaction(entry)
|
||||
useTxCashe.setCurrentTransaction(entry);
|
||||
router.push({
|
||||
pathname: `/stream/${entry.hash}`,
|
||||
query: router.query,
|
||||
|
|
|
@ -49,49 +49,49 @@ const TxABI = (props) => {
|
|||
);
|
||||
};
|
||||
const TxInfo = (props) => {
|
||||
const transaction = props.transaction;
|
||||
const dont_display = (key) => {
|
||||
return !["input"].includes(key)
|
||||
}
|
||||
return (
|
||||
<Box boxShadow="xs" p="6" rounded="md">
|
||||
<StatGroup>
|
||||
<Stat>
|
||||
<StatLabel>Value</StatLabel>
|
||||
<StatNumber>{transaction.tx.value}</StatNumber>
|
||||
<StatHelpText>amount of ETH to transfer in WEI</StatHelpText>
|
||||
</Stat>
|
||||
<Stat>
|
||||
<StatLabel>Gas</StatLabel>
|
||||
<StatNumber>{transaction.tx.gas}</StatNumber>
|
||||
<StatHelpText>gas limit for transaction</StatHelpText>
|
||||
</Stat>
|
||||
<Stat>
|
||||
<StatLabel>Gas price</StatLabel>
|
||||
<StatNumber>{transaction.tx.gasPrice}</StatNumber>
|
||||
<StatHelpText>the fee the sender pays per unit of gas</StatHelpText>
|
||||
</Stat>
|
||||
</StatGroup>
|
||||
const transaction = props.transaction;
|
||||
const dont_display = (key) => {
|
||||
return !["input"].includes(key);
|
||||
};
|
||||
return (
|
||||
<Box boxShadow="xs" p="6" rounded="md">
|
||||
<StatGroup>
|
||||
<Stat>
|
||||
<StatLabel>Value</StatLabel>
|
||||
<StatNumber>{transaction.tx.value}</StatNumber>
|
||||
<StatHelpText>amount of ETH to transfer in WEI</StatHelpText>
|
||||
</Stat>
|
||||
<Stat>
|
||||
<StatLabel>Gas</StatLabel>
|
||||
<StatNumber>{transaction.tx.gas}</StatNumber>
|
||||
<StatHelpText>gas limit for transaction</StatHelpText>
|
||||
</Stat>
|
||||
<Stat>
|
||||
<StatLabel>Gas price</StatLabel>
|
||||
<StatNumber>{transaction.tx.gasPrice}</StatNumber>
|
||||
<StatHelpText>the fee the sender pays per unit of gas</StatHelpText>
|
||||
</Stat>
|
||||
</StatGroup>
|
||||
|
||||
<Table variant="simple" >
|
||||
<Tbody>
|
||||
{Object.keys(transaction.tx).filter(dont_display).map((key) => (
|
||||
(transaction.tx[key] != undefined && <Tr key = {key}>
|
||||
<Td>{key}</Td>
|
||||
<Td>{transaction.tx[key]}</Td>
|
||||
</Tr>)
|
||||
))}
|
||||
</Tbody>
|
||||
</Table>
|
||||
{transaction.tx.input && transaction.tx.input !== "0x" &&
|
||||
<TxABI
|
||||
byteCode={transaction.tx.input}
|
||||
abi={transaction.abi}
|
||||
/>
|
||||
}
|
||||
</Box>
|
||||
|
||||
|
||||
)
|
||||
}
|
||||
<Table variant="simple">
|
||||
<Tbody>
|
||||
{Object.keys(transaction.tx)
|
||||
.filter(dont_display)
|
||||
.map(
|
||||
(key) =>
|
||||
transaction.tx[key] != undefined && (
|
||||
<Tr key={key}>
|
||||
<Td>{key}</Td>
|
||||
<Td>{transaction.tx[key]}</Td>
|
||||
</Tr>
|
||||
)
|
||||
)}
|
||||
</Tbody>
|
||||
</Table>
|
||||
{transaction.tx.input && transaction.tx.input !== "0x" && (
|
||||
<TxABI byteCode={transaction.tx.input} abi={transaction.abi} />
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
export default TxInfo;
|
||||
|
|
|
@ -20,5 +20,5 @@ export { default as useStripe } from "./useStripe";
|
|||
export { default as useSubscriptions } from "./useSubscriptions";
|
||||
export { default as useToast } from "./useToast";
|
||||
export { default as useTxInfo } from "./useTxInfo";
|
||||
export { default as useTxCashe } from "./useTxCache"
|
||||
export { default as useTxCashe } from "./useTxCache";
|
||||
export { default as useUser } from "./useUser";
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
class TxCashe {
|
||||
currentTransaction = undefined
|
||||
getCurrentTransaction(){return this.currentTransaction}
|
||||
setCurrentTransaction(transaction){ this.currentTransaction = transaction}
|
||||
currentTransaction = undefined;
|
||||
getCurrentTransaction() {
|
||||
return this.currentTransaction;
|
||||
}
|
||||
setCurrentTransaction(transaction) {
|
||||
this.currentTransaction = transaction;
|
||||
}
|
||||
}
|
||||
const useTxCashe = new TxCashe();
|
||||
export default useTxCashe;
|
|
@ -4,14 +4,22 @@ import { queryCacheProps } from "./hookCommon";
|
|||
import { useToast } from ".";
|
||||
|
||||
const useTxInfo = (transaction) => {
|
||||
if (!transaction.tx) return {data: "undefined", isLoading: false, isFetchedAfterMount: true, refetch: false, isError: true, error: "undefined"}
|
||||
const toast = useToast();
|
||||
const getTxInfo = async () => {
|
||||
const response = await TxInfoService.getTxInfo(transaction);
|
||||
return response.data;
|
||||
}
|
||||
const { data, isLoading, isFetchedAfterMount, refetch, isError, error } =
|
||||
useQuery(["txinfo", transaction.tx.hash ], getTxInfo, {
|
||||
if (!transaction.tx)
|
||||
return {
|
||||
data: "undefined",
|
||||
isLoading: false,
|
||||
isFetchedAfterMount: true,
|
||||
refetch: false,
|
||||
isError: true,
|
||||
error: "undefined",
|
||||
};
|
||||
const toast = useToast();
|
||||
const getTxInfo = async () => {
|
||||
const response = await TxInfoService.getTxInfo(transaction);
|
||||
return response.data;
|
||||
};
|
||||
const { data, isLoading, isFetchedAfterMount, refetch, isError, error } =
|
||||
useQuery(["txinfo", transaction.tx.hash], getTxInfo, {
|
||||
...queryCacheProps,
|
||||
onError: (error) => toast(error, "error"),
|
||||
});
|
||||
|
|
Ładowanie…
Reference in New Issue