Skip to content

Commit

Permalink
Overview as default & Removed extra request for redundant data (#950)
Browse files Browse the repository at this point in the history
* Overview as default & Remove extra request for redundant data

* TView type added

* show $- instead of $0 if we dont have info
  • Loading branch information
giulianoconti authored Feb 20, 2025
1 parent a417727 commit f7becd0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 23 deletions.
20 changes: 0 additions & 20 deletions src/api/native-token-transfer/NttApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,6 @@ export class NttApi {

const tokenListWithFallback = await Promise.all(
tokenListResponse.map(async item => {
if (!item?.total_value_transferred) {
try {
const summary = await this.getNttTVT({ coingecko_id: item.coingecko_id });
item.total_value_transferred = summary.totalValueTokenTransferred || "0";
} catch (error) {
console.log("Failed to get total value transferred for token", item.symbol);
}
}

if (item.circulating_supply === "0") {
const symbol = item.symbol.toUpperCase();

Expand All @@ -86,17 +77,6 @@ export class NttApi {
return tokenListWithFallback;
}

async getNttTVT({ coingecko_id }: GetSummary): Promise<{ totalValueTokenTransferred: string }> {
const summaryResponse = await this._client.doGet<GetSummaryResult>(
"/native-token-transfer/summary",
{
coingecko_id,
},
);

return { totalValueTokenTransferred: summaryResponse.totalValueTokenTransferred };
}

async getNttSummary({ coingecko_id }: GetSummary): Promise<GetSummaryResult> {
const summaryResponse = await this._client.doGet<GetSummaryResult>(
"/native-token-transfer/summary",
Expand Down
6 changes: 5 additions & 1 deletion src/pages/Analytics/NTT/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ const NTT = () => {
),
tvt: (
<div className="ntt-page-tokens-list-table-item">
<h4>TOTAL VALUE TRANSFERRED</h4>${formatNumber(+item.total_value_transferred, 0)}
<h4>TOTAL VALUE TRANSFERRED</h4>$
{formatNumber(
item?.total_value_transferred ? +item.total_value_transferred : undefined,
0,
)}
</div>
),
volume: (
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Tx/Information/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const Information = ({
const isMainnet = currentNetwork === "Mainnet";

const [showOverview, setShowOverviewState] = useState<TView>(
(searchParams.get("view") as TView) || (isMainnet ? "overview" : "advanced"),
(searchParams.get("view") as TView) || "overview",
);
const setShowOverview = (view: TView) => {
setShowOverviewState(view);
Expand All @@ -85,7 +85,7 @@ const Information = ({

useEffect(() => {
if (!hasMultipleTxs) {
const view = (searchParams.get("view") || (isMainnet ? "overview" : "advanced")) as TView;
const view = (searchParams.get("view") as TView) || "overview";
setShowOverviewState(view);
}
}, [hasMultipleTxs, isMainnet, searchParams]);
Expand Down

0 comments on commit f7becd0

Please sign in to comment.