mirror of
https://github.com/Qortal/q-trade.git
synced 2025-06-18 04:01:21 +00:00
added fee timestamp
This commit is contained in:
parent
74ef469224
commit
ff8e09eed6
@ -5,7 +5,7 @@ import { useIndexedDBContext } from "../../contexts/indexedDBContext";
|
|||||||
|
|
||||||
const fetchTradeInfo = async (qortalAtAddress) => {
|
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()
|
const data = await checkIfOfferingRes.json()
|
||||||
return data
|
return data
|
||||||
};
|
};
|
||||||
|
@ -54,8 +54,8 @@ import {
|
|||||||
MainContainer,
|
MainContainer,
|
||||||
} from "./Table-styles";
|
} from "./Table-styles";
|
||||||
|
|
||||||
// export const baseLocalHost = window.location.host;
|
export const baseLocalHost = window.location.host;
|
||||||
export const baseLocalHost = "devnet-nodes.qortal.link:11111";
|
// export const baseLocalHost = "devnet-nodes.qortal.link:11111";
|
||||||
|
|
||||||
import CloseIcon from "@mui/icons-material/Close";
|
import CloseIcon from "@mui/icons-material/Close";
|
||||||
import ContentCopyIcon from "@mui/icons-material/ContentCopy";
|
import ContentCopyIcon from "@mui/icons-material/ContentCopy";
|
||||||
@ -322,7 +322,7 @@ export const TradeOffers: React.FC<any> = ({
|
|||||||
|
|
||||||
const getNewBlockedTrades = async () => {
|
const getNewBlockedTrades = async () => {
|
||||||
const unconfirmedTransactionsList = 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(
|
var addBlockedTrades = JSON.parse(
|
||||||
localStorage.getItem("failedTrades") || "[]"
|
localStorage.getItem("failedTrades") || "[]"
|
||||||
@ -558,7 +558,7 @@ export const TradeOffers: React.FC<any> = ({
|
|||||||
const getSignedUnlockingFees = useCallback(async () => {
|
const getSignedUnlockingFees = useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`http://devnet-nodes.qortal.link:11112/crosschain/signedfees`
|
`/crosschain/signedfees`
|
||||||
);
|
);
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
if (data && Array.isArray(data)) {
|
if (data && Array.isArray(data)) {
|
||||||
|
@ -28,6 +28,7 @@ import { CustomInput, CustomLabel } from "./CreateSell";
|
|||||||
import { Spacer } from "../common/Spacer";
|
import { Spacer } from "../common/Spacer";
|
||||||
import { usePublish, Service, QortalGetMetadata } from "qapp-core";
|
import { usePublish, Service, QortalGetMetadata } from "qapp-core";
|
||||||
import { SetLeftFeature } from "ag-grid-community";
|
import { SetLeftFeature } from "ag-grid-community";
|
||||||
|
import { formatTimestampForum } from "../../utils/formatTime";
|
||||||
|
|
||||||
function calculateFeeFromRate(feePerKb, sizeInBytes) {
|
function calculateFeeFromRate(feePerKb, sizeInBytes) {
|
||||||
const fee = (feePerKb / 1000) * sizeInBytes;
|
const fee = (feePerKb / 1000) * sizeInBytes;
|
||||||
@ -50,6 +51,7 @@ export const FeeManager = ({ selectedCoin, setFee, fee }) => {
|
|||||||
const [recommendedFee, setRecommendedFee] = useState("m");
|
const [recommendedFee, setRecommendedFee] = useState("m");
|
||||||
const [openAlert, setOpenAlert] = useState(false);
|
const [openAlert, setOpenAlert] = useState(false);
|
||||||
const [info, setInfo] = useState<any>(null);
|
const [info, setInfo] = useState<any>(null);
|
||||||
|
const [feeTimestamp, setFeeTimestamp] = useState(null)
|
||||||
const { getCoinLabel } = useContext(gameContext);
|
const { getCoinLabel } = useContext(gameContext);
|
||||||
const handleCloseAlert = (
|
const handleCloseAlert = (
|
||||||
event?: React.SyntheticEvent | Event,
|
event?: React.SyntheticEvent | Event,
|
||||||
@ -86,7 +88,6 @@ export const FeeManager = ({ selectedCoin, setFee, fee }) => {
|
|||||||
},
|
},
|
||||||
1800000
|
1800000
|
||||||
);
|
);
|
||||||
console.log('response', response)
|
|
||||||
if ((response !== null && response !== undefined) && !isNaN(+response)) {
|
if ((response !== null && response !== undefined) && !isNaN(+response)) {
|
||||||
setFee(response);
|
setFee(response);
|
||||||
}
|
}
|
||||||
@ -182,20 +183,25 @@ export const FeeManager = ({ selectedCoin, setFee, fee }) => {
|
|||||||
const getLatestFees = useCallback(async () => {
|
const getLatestFees = useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
const res = await fetch(
|
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();
|
const data = await res.json();
|
||||||
if (data && data?.length > 0) {
|
if (data && data?.length > 0) {
|
||||||
setFeeLocation(data[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(() => {
|
useEffect(() => {
|
||||||
getLatestFees();
|
getLatestFees();
|
||||||
}, [getLatestFees]);
|
}, [getLatestFees]);
|
||||||
|
|
||||||
console.log('fee', fee)
|
|
||||||
|
|
||||||
if (fee === null || fee === undefined) return;
|
if (fee === null || fee === undefined) return;
|
||||||
return (
|
return (
|
||||||
@ -262,10 +268,12 @@ export const FeeManager = ({ selectedCoin, setFee, fee }) => {
|
|||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
alignItems: 'center'
|
alignItems: 'center'
|
||||||
}}>
|
}}>
|
||||||
<CustomLabel htmlFor="standard-adornment-name">
|
<CustomLabel sx={{
|
||||||
Recommended fee selection ( in sats)
|
fontSize: '16px'
|
||||||
|
}} htmlFor="standard-adornment-name">
|
||||||
|
Recommended fee selection (in sats)
|
||||||
</CustomLabel>
|
</CustomLabel>
|
||||||
|
|
||||||
<Spacer height="10px" />
|
<Spacer height="10px" />
|
||||||
<ToggleButtonGroup
|
<ToggleButtonGroup
|
||||||
color="primary"
|
color="primary"
|
||||||
@ -288,15 +296,23 @@ export const FeeManager = ({ selectedCoin, setFee, fee }) => {
|
|||||||
{recommendedFeeDisplay && (
|
{recommendedFeeDisplay && (
|
||||||
<>
|
<>
|
||||||
<Spacer height="15px" />
|
<Spacer height="15px" />
|
||||||
|
<Box sx={{
|
||||||
|
width: '100%',
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'center'
|
||||||
|
}}>
|
||||||
<Typography
|
<Typography
|
||||||
sx={{
|
sx={{
|
||||||
color: "white",
|
color: "white",
|
||||||
fontSize: "18px",
|
fontSize: "18px",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
New fee:{" "}
|
<span style={{
|
||||||
{calculateFeeFromRate(recommendedFeeDisplay, 300)}
|
fontWeight: 'bold'
|
||||||
|
}}> New fee:</span>{" "}
|
||||||
|
{calculateFeeFromRate(recommendedFeeDisplay, 300)} sats
|
||||||
</Typography>
|
</Typography>
|
||||||
|
</Box>
|
||||||
<Spacer height="10px" />
|
<Spacer height="10px" />
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
@ -321,6 +337,8 @@ export const FeeManager = ({ selectedCoin, setFee, fee }) => {
|
|||||||
is approximately 300 kB in size.
|
is approximately 300 kB in size.
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
|
<Spacer height="10px"/>
|
||||||
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
@ -370,6 +388,9 @@ export const FeeManager = ({ selectedCoin, setFee, fee }) => {
|
|||||||
/>
|
/>
|
||||||
<Typography>Update fee</Typography>
|
<Typography>Update fee</Typography>
|
||||||
</ButtonBase>
|
</ButtonBase>
|
||||||
|
{!hideRecommendations && feeTimestamp && (
|
||||||
|
<CustomLabel >*Recommended fees last updated: {formatTimestampForum(feeTimestamp)}</CustomLabel>
|
||||||
|
)}
|
||||||
</CoinActionContainer>
|
</CoinActionContainer>
|
||||||
</ReusableModal>
|
</ReusableModal>
|
||||||
)}
|
)}
|
||||||
|
@ -102,7 +102,7 @@ export default function UnsignedFees({ qortAddress }) {
|
|||||||
|
|
||||||
const getUnsignedFees = useCallback(async (address)=> {
|
const getUnsignedFees = useCallback(async (address)=> {
|
||||||
try {
|
try {
|
||||||
const url = `http://devnet-nodes.qortal.link:11112/crosschain/unsignedfees/${address}`
|
const url = `/crosschain/unsignedfees/${address}`
|
||||||
const res = await fetch(url)
|
const res = await fetch(url)
|
||||||
const data = await res.json()
|
const data = await res.json()
|
||||||
if(data && data.length > 0){
|
if(data && data.length > 0){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user