added fee timestamp

This commit is contained in:
PhilReact 2025-05-03 02:21:16 +03:00
parent 74ef469224
commit ff8e09eed6
4 changed files with 36 additions and 15 deletions

View File

@ -5,7 +5,7 @@ import { useIndexedDBContext } from "../../contexts/indexedDBContext";
const fetchTradeInfo = async (qortalAtAddress) => {
const checkIfOfferingRes = await fetch(`http://devnet-nodes.qortal.link:11112/crosschain/trade/${qortalAtAddress}`)
const checkIfOfferingRes = await fetch(`/crosschain/trade/${qortalAtAddress}`)
const data = await checkIfOfferingRes.json()
return data
};

View File

@ -54,8 +54,8 @@ import {
MainContainer,
} from "./Table-styles";
// export const baseLocalHost = window.location.host;
export const baseLocalHost = "devnet-nodes.qortal.link:11111";
export const baseLocalHost = window.location.host;
// export const baseLocalHost = "devnet-nodes.qortal.link:11111";
import CloseIcon from "@mui/icons-material/Close";
import ContentCopyIcon from "@mui/icons-material/ContentCopy";
@ -322,7 +322,7 @@ export const TradeOffers: React.FC<any> = ({
const getNewBlockedTrades = async () => {
const unconfirmedTransactionsList = async () => {
const unconfirmedTransactionslUrl = `http://devnet-nodes.qortal.link:11112/transactions/unconfirmed?txType=MESSAGE&limit=0&reverse=true`;
const unconfirmedTransactionslUrl = `/transactions/unconfirmed?txType=MESSAGE&limit=0&reverse=true`;
var addBlockedTrades = JSON.parse(
localStorage.getItem("failedTrades") || "[]"
@ -558,7 +558,7 @@ export const TradeOffers: React.FC<any> = ({
const getSignedUnlockingFees = useCallback(async () => {
try {
const response = await fetch(
`http://devnet-nodes.qortal.link:11112/crosschain/signedfees`
`/crosschain/signedfees`
);
const data = await response.json();
if (data && Array.isArray(data)) {

View File

@ -28,6 +28,7 @@ import { CustomInput, CustomLabel } from "./CreateSell";
import { Spacer } from "../common/Spacer";
import { usePublish, Service, QortalGetMetadata } from "qapp-core";
import { SetLeftFeature } from "ag-grid-community";
import { formatTimestampForum } from "../../utils/formatTime";
function calculateFeeFromRate(feePerKb, sizeInBytes) {
const fee = (feePerKb / 1000) * sizeInBytes;
@ -50,6 +51,7 @@ export const FeeManager = ({ selectedCoin, setFee, fee }) => {
const [recommendedFee, setRecommendedFee] = useState("m");
const [openAlert, setOpenAlert] = useState(false);
const [info, setInfo] = useState<any>(null);
const [feeTimestamp, setFeeTimestamp] = useState(null)
const { getCoinLabel } = useContext(gameContext);
const handleCloseAlert = (
event?: React.SyntheticEvent | Event,
@ -86,7 +88,6 @@ export const FeeManager = ({ selectedCoin, setFee, fee }) => {
},
1800000
);
console.log('response', response)
if ((response !== null && response !== undefined) && !isNaN(+response)) {
setFee(response);
}
@ -182,20 +183,25 @@ export const FeeManager = ({ selectedCoin, setFee, fee }) => {
const getLatestFees = useCallback(async () => {
try {
const res = await fetch(
`http://devnet-nodes.qortal.link:11112/arbitrary/resources/searchsimple?service=JSON&identifier=foreign-fee&name=Foreign-Fee-Publisher&prefix=true&limit=1&reverse=true`
`/arbitrary/resources/searchsimple?service=JSON&identifier=foreign-fee&name=Foreign-Fee-Publisher&prefix=true&limit=1&reverse=true`
);
const data = await res.json();
if (data && data?.length > 0) {
setFeeLocation(data[0]);
const id = data[0].identifier;
const parts = id.split("-");
const timestampSec = parseInt(parts[2], 10);
setFeeTimestamp(timestampSec)
}
} catch (error) {}
} catch (error) {
console.error(error)
}
}, []);
useEffect(() => {
getLatestFees();
}, [getLatestFees]);
console.log('fee', fee)
if (fee === null || fee === undefined) return;
return (
@ -262,8 +268,10 @@ export const FeeManager = ({ selectedCoin, setFee, fee }) => {
flexDirection: 'column',
alignItems: 'center'
}}>
<CustomLabel htmlFor="standard-adornment-name">
Recommended fee selection ( in sats)
<CustomLabel sx={{
fontSize: '16px'
}} htmlFor="standard-adornment-name">
Recommended fee selection (in sats)
</CustomLabel>
<Spacer height="10px" />
@ -288,15 +296,23 @@ export const FeeManager = ({ selectedCoin, setFee, fee }) => {
{recommendedFeeDisplay && (
<>
<Spacer height="15px" />
<Box sx={{
width: '100%',
display: 'flex',
justifyContent: 'center'
}}>
<Typography
sx={{
color: "white",
fontSize: "18px",
}}
>
New fee:{" "}
{calculateFeeFromRate(recommendedFeeDisplay, 300)}
<span style={{
fontWeight: 'bold'
}}> New fee:</span>{" "}
{calculateFeeFromRate(recommendedFeeDisplay, 300)} sats
</Typography>
</Box>
<Spacer height="10px" />
<Box
sx={{
@ -321,6 +337,8 @@ export const FeeManager = ({ selectedCoin, setFee, fee }) => {
is approximately 300 kB in size.
</Typography>
</Box>
<Spacer height="10px"/>
</>
)}
</Box>
@ -370,6 +388,9 @@ export const FeeManager = ({ selectedCoin, setFee, fee }) => {
/>
<Typography>Update fee</Typography>
</ButtonBase>
{!hideRecommendations && feeTimestamp && (
<CustomLabel >*Recommended fees last updated: {formatTimestampForum(feeTimestamp)}</CustomLabel>
)}
</CoinActionContainer>
</ReusableModal>
)}

View File

@ -102,7 +102,7 @@ export default function UnsignedFees({ qortAddress }) {
const getUnsignedFees = useCallback(async (address)=> {
try {
const url = `http://devnet-nodes.qortal.link:11112/crosschain/unsignedfees/${address}`
const url = `/crosschain/unsignedfees/${address}`
const res = await fetch(url)
const data = await res.json()
if(data && data.length > 0){