fix(explorer): reduce limit of txs from 100 to 20 (#1985)
This commit is contained in:
parent
b4ab94b54b
commit
cb9ceb2f7d
@ -17,17 +17,26 @@ export interface IUseTxsData {
|
|||||||
filters?: string;
|
filters?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getTxsDataUrl = ({ limit = 10, filters = '' }) => {
|
interface IGetTxsDataUrl {
|
||||||
let url = `${DATA_SOURCES.blockExplorerUrl}/transactions?limit=${limit}`;
|
limit?: string;
|
||||||
|
filters?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getTxsDataUrl = ({ limit, filters }: IGetTxsDataUrl) => {
|
||||||
|
const url = new URL(`${DATA_SOURCES.blockExplorerUrl}/transactions`);
|
||||||
|
|
||||||
|
if (limit) {
|
||||||
|
url.searchParams.append('limit', limit);
|
||||||
|
}
|
||||||
|
|
||||||
if (filters) {
|
if (filters) {
|
||||||
url = `${url}&${filters}`;
|
url.searchParams.append('filters', filters);
|
||||||
}
|
}
|
||||||
|
|
||||||
return url;
|
return url;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useTxsData = ({ limit = 10, filters }: IUseTxsData) => {
|
export const useTxsData = ({ limit, filters }: IUseTxsData) => {
|
||||||
const [{ txsData, hasMoreTxs, lastCursor }, setTxsState] =
|
const [{ txsData, hasMoreTxs, lastCursor }, setTxsState] =
|
||||||
useState<TxsStateProps>({
|
useState<TxsStateProps>({
|
||||||
txsData: [],
|
txsData: [],
|
||||||
@ -35,12 +44,12 @@ export const useTxsData = ({ limit = 10, filters }: IUseTxsData) => {
|
|||||||
lastCursor: '',
|
lastCursor: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
const url = getTxsDataUrl({ limit, filters });
|
const url = getTxsDataUrl({ limit: limit?.toString(), filters });
|
||||||
|
|
||||||
const {
|
const {
|
||||||
state: { data, error, loading },
|
state: { data, error, loading },
|
||||||
refetch,
|
refetch,
|
||||||
} = useFetch<BlockExplorerTransactions>(url, {}, false);
|
} = useFetch<BlockExplorerTransactions>(url.href, {}, false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data?.transactions?.length) {
|
if (data?.transactions?.length) {
|
||||||
|
@ -4,7 +4,7 @@ import { BlocksRefetch } from '../../../components/blocks';
|
|||||||
import { TxsInfiniteList, TxsStatsInfo } from '../../../components/txs';
|
import { TxsInfiniteList, TxsStatsInfo } from '../../../components/txs';
|
||||||
import { useTxsData } from '../../../hooks/use-txs-data';
|
import { useTxsData } from '../../../hooks/use-txs-data';
|
||||||
|
|
||||||
const BE_TXS_PER_REQUEST = 100;
|
const BE_TXS_PER_REQUEST = 20;
|
||||||
|
|
||||||
export const TxsList = () => {
|
export const TxsList = () => {
|
||||||
const { hasMoreTxs, loadTxs, error, txsData, refreshTxs, loading } =
|
const { hasMoreTxs, loadTxs, error, txsData, refreshTxs, loading } =
|
||||||
|
Loading…
Reference in New Issue
Block a user