Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final fixes #373

Merged
merged 19 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
9e3531e
fix: removed all tab from line graph
AbbasAliLokhandwala Jul 5, 2024
4da5620
chore: add Eridanus to config
AbbasAliLokhandwala Jul 5, 2024
0ffa7d6
chore: make Eridanus stakable
AbbasAliLokhandwala Jul 5, 2024
0ae45e9
fix: tooltip fix
AbbasAliLokhandwala Jul 5, 2024
7ce1e57
fix: view in explorer button
AbbasAliLokhandwala Jul 5, 2024
6d0e3d9
fix: notifications, chat, axelar bridge and .Fet domains disabled
AbbasAliLokhandwala Jul 5, 2024
b0a6135
fix: network switch txn in-progress banner and unconfirmed txn status
AbbasAliLokhandwala Jul 5, 2024
022a49b
chore: stakable rewards available card
AbbasAliLokhandwala Jul 5, 2024
98c173a
fix: reward card gradient borders
AbbasAliLokhandwala Jul 7, 2024
a29e901
fix: stake, unstake and redelegate onFulfil redirect to stake page
AbbasAliLokhandwala Jul 8, 2024
a2df33f
fix: migrate native bridge to new ui and fee component fix
AbbasAliLokhandwala Jul 8, 2024
c1c1bdb
fix: chat disabled and more page scroll
AbbasAliLokhandwala Jul 8, 2024
995f751
fix: claim rewards button
AbbasAliLokhandwala Jul 8, 2024
72ee773
fix: close dropdown on network select
AbbasAliLokhandwala Jul 8, 2024
3a9199d
fix: coingecko id update for networks
AbbasAliLokhandwala Jul 8, 2024
bee9783
fix: line graph cache and error control
AbbasAliLokhandwala Jul 9, 2024
ee3df13
fix: remove extra $ from dorado network balances
AbbasAliLokhandwala Jul 9, 2024
89b75a0
fix: cachedPrice undefined issue on reload
AbbasAliLokhandwala Jul 10, 2024
51f388b
fix: navigate to activity page after any stake related txn
AbbasAliLokhandwala Jul 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ import {
import { observer } from "mobx-react-lite";
import { useIntl } from "react-intl";
import { validateAgentAddress } from "@utils/validate-agent";
import { CHAIN_ID_DORADO, CHAIN_ID_FETCHHUB } from "../../config.ui.var";
import {
CHAIN_ID_DORADO,
CHAIN_ID_ERIDANUS,
CHAIN_ID_FETCHHUB,
} from "../../config.ui.var";
import { getBeneficiaryAddress } from "../../name-service/fns-apis";
import { Card } from "../card";
import { Dropdown } from "@components-v2/dropdown";
Expand Down Expand Up @@ -135,7 +139,7 @@ export const AddressInput: FunctionComponent<AddressInputProps> = observer(
"isICNSEnabled" in recipientConfig &&
recipientConfig.isICNSEnabled &&
value.length > 0 &&
![CHAIN_ID_DORADO, CHAIN_ID_FETCHHUB].includes(
![CHAIN_ID_DORADO, CHAIN_ID_FETCHHUB, CHAIN_ID_ERIDANUS].includes(
recipientConfig.chainId
) &&
value[value.length - 1] === "." &&
Expand All @@ -149,7 +153,7 @@ export const AddressInput: FunctionComponent<AddressInputProps> = observer(

const updateFNSValue = async (value: string) => {
if (
[CHAIN_ID_DORADO, CHAIN_ID_FETCHHUB].includes(
[CHAIN_ID_DORADO, CHAIN_ID_FETCHHUB, CHAIN_ID_ERIDANUS].includes(
recipientConfig.chainId
) &&
value.length > 5 &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,9 @@ export const FeeButtonsInner: FunctionComponent<
color: "white",
}}
>
{feeConfig.feeType === "low"
{feeButtonState.isGasInputOpen
? gasConfig.gasRaw
: feeConfig.feeType === "low"
? lowFee.hideIBCMetadata(true).trim(true).toMetricPrefix(isEvm)
: feeConfig.feeType === "average"
? averageFee
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ const tabs = [
},
{
id: "1Y",
duration: 360,
},
{
id: "All",
duration: 3600,
duration: 365,
},
];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { formatTimestamp } from "@utils/parse-timestamp-to-date";
import axios from "axios";
import moment from "moment";
import React, { useEffect, useMemo, useState } from "react";
import { Line } from "react-chartjs-2";
import { chartOptions } from "./chart-options";
Expand Down Expand Up @@ -33,17 +33,29 @@ export const LineGraph: React.FC<LineGraphProps> = ({
);

const cachedPrices = useMemo(() => {
const cachedData = sessionStorage.getItem(cacheKey);
const cachedData = localStorage.getItem(cacheKey);
return cachedData ? JSON.parse(cachedData) : null;
}, [cacheKey]);

const isCachedPricesValid = (updatedAt: any) => {
const currTime = Date.parse(new Date().toString());
const prevUpdatedAt = Date.parse(updatedAt.toString());

return currTime - prevUpdatedAt < 10 * 60 * 1000;
};

useEffect(() => {
const fetchPrices = async () => {
setLoading(true);
setError("");
try {
let newPrices: any[] = [];
if (cachedPrices) {
newPrices = cachedPrices;
if (
cachedPrices &&
!!cachedPrices.updatedAt &&
isCachedPricesValid(cachedPrices.updatedAt)
) {
newPrices = cachedPrices.newPrices;
} else {
const apiUrl = `https://api.coingecko.com/api/v3/coins/${tokenName}/market_chart`;
const params = { vs_currency: "usd", days: duration };
Expand All @@ -54,7 +66,12 @@ export const LineGraph: React.FC<LineGraphProps> = ({
price: price[1],
}));

sessionStorage.setItem(cacheKey, JSON.stringify(newPrices));
const lastUpdatedPrice = {
newPrices,
updatedAt: new Date(),
};

localStorage.setItem(cacheKey, JSON.stringify(lastUpdatedPrice));
}
if (newPrices.length > 0) {
const firstValue = newPrices[0].price || 0;
Expand All @@ -66,19 +83,27 @@ export const LineGraph: React.FC<LineGraphProps> = ({
else if (duration === 7) time = "1 WEEK";
else if (duration === 30) time = "1 MONTH";
else if (duration === 90) time = "3 MONTH";
else if (duration === 360) time = "1 YEAR";
else if (duration === 365) time = "1 YEAR";
else if (duration === 100000) time = "ALL";

const type = diff >= 0 ? "positive" : "negative";

setTokenState({ diff: Math.abs(percentageDiff), time, type });
}
setPrices(newPrices);
setLoading(false);
} catch (error) {
console.error("Error fetching data:", error.message);
if (error.response.status === 429) {
setTimeout(() => {
fetchPrices();
}, 10 * 1000);
console.log("Too many request error, trying to fetch again");
if (cachedPrices) setPrices(cachedPrices.newPrices);
return;
}

console.log("Error fetching data:", { error });
setError("Unable to fetch data. Please try again.");
} finally {
setLoading(false);
}
};

Expand All @@ -87,9 +112,13 @@ export const LineGraph: React.FC<LineGraphProps> = ({

const chartData = {
labels: prices.map((priceData: any) => {
const time = formatTimestamp(
new Date(priceData.timestamp).toLocaleString()
);
let format = "MMM DD, YYYY";
if (duration === 1) format = "MMM DD, HH:mm";
else if (duration === 7) format = "MMM DD, HH:mm";
else if (duration === 30) format = "MMM DD";
else if (duration === 90) format = "MMM DD YYYY";
else if (duration === 365) format = "MMM DD, YYYY";
const time = moment(priceData.timestamp).format(format);
return time;
}),
datasets: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import style from "./style.module.scss";
import { titleCase } from "@utils/format";
import { Address } from "@components/address";
import { useNavigate } from "react-router";
import { Link } from "react-router-dom";
import { VALIDATOR_URL } from "../../config.ui.var";

interface ItemData {
title: string;
Expand All @@ -18,6 +20,7 @@ export const StakeValidatorCard = ({
commission,
status,
apr,
chainID,
}: {
trailingIcon?: any;
thumbnailUrl?: any;
Expand All @@ -28,6 +31,7 @@ export const StakeValidatorCard = ({
commission?: string;
status?: string;
apr?: string;
chainID: string;
}) => {
const navigate = useNavigate();

Expand Down Expand Up @@ -134,17 +138,25 @@ export const StakeValidatorCard = ({
))}
</div>

<div
style={{
color: "#BFAFFD",
fontFamily: "Lexend",
fontSize: "12px",
fontWeight: 400,
cursor: "pointer",
<Link
onClick={(e) => {
e.stopPropagation();
}}
to={`${VALIDATOR_URL[chainID]}/${validatorAddress}`}
target="_blank"
>
View in explorer
</div>
<div
style={{
color: "#BFAFFD",
fontFamily: "Lexend",
fontSize: "12px",
fontWeight: 400,
cursor: "pointer",
}}
>
View in explorer
</div>
</Link>
</div>
);
};
Loading
Loading