Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 215-change-content-of-operation-card
  • 216-create-table-for-operations
  • 249-404-not-found-after-choosing-an-account-from-search-bar-with-enter
  • 366-allow-env-level-configuration-of-default-site-colors-for-both-light-and-dark-modes
  • 504-incorrect-weight_threshold-indications-for-hive-fund-steem-dao-accounts
  • adubel/fix-skiped-tests
  • adubel/test-e2e-fix-locators
  • adubel/test-improvements
  • bw_format_msg_tweaks
  • copy_of_add_charts_to_balance_history
  • delrifai/#356_calculate_hive_power_for_voters_and_votes_history
  • delrifai/#372_fix_pagination_issues
  • delrifai/#384_add_scroll_left_right_to_table
  • delrifai/#394_add_charts_to_balance_history
  • delrifai/#433_add_noResult_component
  • delrifai/#505_fix_no_filter_balance_history
  • delrifai/all_blocks_fixes_1
  • develop
  • jlachor/healthchecker
  • jlachor/local-healthchecker
  • jlachor/virtual-in-raw
  • kbotor/80-configure-ssl-for-staging-and-test-deployments
  • kbotor/cors-fix
  • lbudginas/#240_transaction_link_scroll
  • lbudginas/#276_pretty_json_operation_view
  • lbudginas/#287_witness_table_update
  • lbudginas/#304_convert_vests_to_hp_account_page
  • lbudginas/#374_calendar_dates_selection_bug
  • lbudginas/#385_single_post_page
  • lbudginas/#390_auto_suggest_bg_bug
  • lbudginas/#396_account_operations_table_bug
  • lbudginas/#439_account_page_request_optimisation
  • lbudginas/#443_post_page_links_bug
  • lbudginas/#447_post_dollar_value_not_visible
  • lbudginas/#523_tooltips_on_mobile
  • lbudginas/account_page_votes_history
  • lbudginas/aggregate_operations_block_page
  • lbudginas/clear_storage_on_invalid_api_address
  • lbudginas/refactor_url_param_build
  • lbudginas/replace-date-time-pickers-shadcn-ui
  • master
  • mcfarhat-283-add_live_profile_tracking
  • mcfarhat-283-live_profile_tracking_updates
  • mcfarhat-285-add_vesting_delegations
  • mcfarhat-295-witness_page_feed_age
  • mcfarhat-301-hide_disabled_witnesses
  • mcfarhat-302-fix_crash_user_profile
  • mcfarhat-316-fix_issue_with_delegated_values_wallet
  • mcfarhat-332-fix_update_date_picker
  • mcfarhat-fix_delegated_values_display
  • test-tag
51 results

Target

Select target project
  • hive/block_explorer_ui
1 result
Select Git revision
  • 215-change-content-of-operation-card
  • 216-create-table-for-operations
  • 249-404-not-found-after-choosing-an-account-from-search-bar-with-enter
  • 366-allow-env-level-configuration-of-default-site-colors-for-both-light-and-dark-modes
  • 504-incorrect-weight_threshold-indications-for-hive-fund-steem-dao-accounts
  • adubel/fix-skiped-tests
  • adubel/test-e2e-fix-locators
  • adubel/test-improvements
  • bw_format_msg_tweaks
  • copy_of_add_charts_to_balance_history
  • delrifai/#356_calculate_hive_power_for_voters_and_votes_history
  • delrifai/#372_fix_pagination_issues
  • delrifai/#384_add_scroll_left_right_to_table
  • delrifai/#394_add_charts_to_balance_history
  • delrifai/#433_add_noResult_component
  • delrifai/#505_fix_no_filter_balance_history
  • delrifai/all_blocks_fixes_1
  • develop
  • jlachor/healthchecker
  • jlachor/local-healthchecker
  • jlachor/virtual-in-raw
  • kbotor/80-configure-ssl-for-staging-and-test-deployments
  • kbotor/cors-fix
  • lbudginas/#240_transaction_link_scroll
  • lbudginas/#276_pretty_json_operation_view
  • lbudginas/#287_witness_table_update
  • lbudginas/#304_convert_vests_to_hp_account_page
  • lbudginas/#374_calendar_dates_selection_bug
  • lbudginas/#385_single_post_page
  • lbudginas/#390_auto_suggest_bg_bug
  • lbudginas/#396_account_operations_table_bug
  • lbudginas/#439_account_page_request_optimisation
  • lbudginas/#443_post_page_links_bug
  • lbudginas/#447_post_dollar_value_not_visible
  • lbudginas/#523_tooltips_on_mobile
  • lbudginas/account_page_votes_history
  • lbudginas/aggregate_operations_block_page
  • lbudginas/clear_storage_on_invalid_api_address
  • lbudginas/refactor_url_param_build
  • lbudginas/replace-date-time-pickers-shadcn-ui
  • master
  • mcfarhat-283-add_live_profile_tracking
  • mcfarhat-283-live_profile_tracking_updates
  • mcfarhat-285-add_vesting_delegations
  • mcfarhat-295-witness_page_feed_age
  • mcfarhat-301-hide_disabled_witnesses
  • mcfarhat-302-fix_crash_user_profile
  • mcfarhat-316-fix_issue_with_delegated_values_wallet
  • mcfarhat-332-fix_update_date_picker
  • mcfarhat-fix_delegated_values_display
  • test-tag
51 results
Show changes
Commits on Source (4)
import {
LineChart,
Line,
XAxis,
YAxis,
Tooltip,
ResponsiveContainer,
Legend,
} from "recharts";
import Hive from "@/types/Hive";
import moment from "moment";
import { useHiveChainContext } from "@/contexts/HiveChainContext";
import { Card, CardContent, CardHeader } from "../ui/card";
import { Loader2 } from "lucide-react";
import { colorMap } from "../balanceHistory/BalanceHistoryChart";
const CustomTooltip = ({
active,
payload,
}: {
active?: boolean;
payload?: any[];
}) => {
if (active && payload && payload.length) {
return (
<div className="bg-buttonHover text-text p-2 rounded-xl">
{payload.map(({ payload: { date, avgPrice, volume } }) => {
return (
<div key={date}>
<p>{`Date: ${date}`}</p>
<p>{`Average Price: $${avgPrice}`}</p>
<p>{`Volume: ${volume.toLocaleString("en-US")} HIVE`}</p>
</div>
);
})}
</div>
);
}
return null;
};
// Using volume to calculate the average daily price of HIVE
const calculateAvgHivePrice = (
hive: Hive.MarketData,
nonHive: Hive.MarketData
) => {
const hiveVolume = hive.volume;
const nonHiveVolume = nonHive.volume;
return (nonHiveVolume / hiveVolume).toFixed(4);
};
interface MarketChartProps {
data: Hive.MarketHistory | undefined;
isLoading: boolean;
strokeColor: string;
}
interface ChartData {
date: string;
avgPrice: string;
volume: number;
}
const MarketHistoryChart: React.FC<MarketChartProps> = ({
data,
isLoading,
strokeColor,
}) => {
const { hiveChain } = useHiveChainContext();
if (!data || !hiveChain) return;
if (isLoading) {
return (
<div className="flex justify-center items-center">
<Loader2 className="animate-spin mt-1 h-16 w-10 ml-10 dark:text-white" />
</div>
);
}
const chartData = data.buckets.map((bucket) => {
const { hive, non_hive } = bucket;
const hiveAveragePrice = calculateAvgHivePrice(hive, non_hive);
return {
date: moment(bucket.open).format("MMM D"),
avgPrice: hiveAveragePrice,
volume: bucket.hive.volume,
};
});
const lastHivePrice = chartData[chartData.length - 1].avgPrice;
const minValue = Math.min(
...chartData.map((d: ChartData) => parseFloat(d.avgPrice))
);
const maxValue = Math.max(
...chartData.map((d: ChartData) => parseFloat(d.avgPrice))
);
return (
<Card className="mb-3">
<CardHeader className="flex justify-between items-center px-1 py-3">
<h2 className="text-lg font-semibold">Hive Price Chart</h2>
</CardHeader>
<CardContent>
<ResponsiveContainer
width="100%"
height={300}
>
<LineChart data={chartData}>
<XAxis
dataKey="date"
stroke={strokeColor}
/>
<YAxis
dataKey="avgPrice"
domain={[minValue, maxValue]}
stroke={strokeColor}
/>
<Tooltip content={<CustomTooltip />} />
<Legend
verticalAlign="top"
height={36}
/>
<Line
name={`Hive Price: $${lastHivePrice}`}
type="monotone"
dataKey="avgPrice"
stroke={colorMap.HIVE}
dot={false}
strokeWidth={2}
/>
</LineChart>
</ResponsiveContainer>
</CardContent>
</Card>
);
};
export default MarketHistoryChart;
import { useQuery, UseQueryResult } from "@tanstack/react-query";
import fetchingService from "@/services/FetchingService";
import Hive from "@/types/Hive";
const useMarketHistory = (
bucketSeconds: number,
start: string,
end: string
) => {
const {
data: marketHistory,
isLoading: isMarketHistoryLoading,
isError: isMarketHistoryError,
}: UseQueryResult<Hive.MarketHistory> = useQuery({
queryKey: ["account_details", bucketSeconds, start, end],
queryFn: () => fetchingService.getMarketHistory(bucketSeconds, start, end),
refetchOnWindowFocus: false,
});
return {
marketHistory,
isMarketHistoryLoading,
isMarketHistoryError,
};
};
export default useMarketHistory;
...@@ -39,6 +39,12 @@ type ExplorerNodeApi = { ...@@ -39,6 +39,12 @@ type ExplorerNodeApi = {
Hive.HivePosts Hive.HivePosts
>; >;
}; };
market_history_api: {
get_market_history: TWaxApiRequest<
{ bucket_seconds: number; start: string; end: string },
Hive.MarketHistory[]
>;
};
}; };
class FetchingService { class FetchingService {
...@@ -446,25 +452,39 @@ class FetchingService { ...@@ -446,25 +452,39 @@ class FetchingService {
}); });
} }
async geAccountAggregatedtBalanceHistory( async geAccountAggregatedtBalanceHistory(
accountName: string, accountName: string,
coinType: string, coinType: string,
granularity : "daily"|"monthly"|"yearly", granularity: "daily" | "monthly" | "yearly",
direction: "asc" | "desc", direction: "asc" | "desc",
fromBlock?: Date | number | undefined, fromBlock?: Date | number | undefined,
toBlock?: Date | number | undefined toBlock?: Date | number | undefined
): Promise<Hive.AccountAggregatedBalanceHistoryResponse> { ): Promise<Hive.AccountAggregatedBalanceHistoryResponse> {
return await this.extendedHiveChain!.restApi["balance-api"].aggregatedHistory({ return await this.extendedHiveChain!.restApi[
"balance-api"
].aggregatedHistory({
accountName, accountName,
"coin-type": coinType, "coin-type": coinType,
"granularity":granularity, granularity: granularity,
direction: direction, direction: direction,
"from-block": fromBlock, "from-block": fromBlock,
"to-block": toBlock, "to-block": toBlock,
}); });
} }
async getMarketHistory(
bucketSeconds: number,
start: string,
end: string
): Promise<Hive.MarketHistory[]> {
return await this.extendedHiveChain!.api.market_history_api.get_market_history(
{
bucket_seconds: bucketSeconds,
start,
end,
}
);
}
} }
const fetchingService = new FetchingService(); const fetchingService = new FetchingService();
......
...@@ -789,7 +789,7 @@ namespace Hive { ...@@ -789,7 +789,7 @@ namespace Hive {
prev_balance!: number; prev_balance!: number;
min_balance!: number; min_balance!: number;
max_balance!: number; max_balance!: number;
date!:Date; date!: Date;
} }
export class Delegation { export class Delegation {
...@@ -811,6 +811,32 @@ namespace Hive { ...@@ -811,6 +811,32 @@ namespace Hive {
total_pages!: number; total_pages!: number;
operations_result!: TwoDirectionDelegations[]; operations_result!: TwoDirectionDelegations[];
} }
export class MarketHistory {
buckets!: MarketBucket[];
}
export class MarketBucket {
id!: number;
open!: string;
seconds!: number;
hive!: MarketData;
symbol!: MarketSymbol;
non_hive!: MarketData;
}
export class MarketData {
high!: number;
low!: number;
open!: number;
close!: number;
volume!: number;
}
export class MarketSymbol {
nai!: string;
precision!: number;
}
} }
export default Hive; export default Hive;