diff --git a/package.json b/package.json index 83e787d9c..5cce8449d 100644 --- a/package.json +++ b/package.json @@ -39,10 +39,10 @@ "devDependencies": { "@sentry/webpack-plugin": "2.7.1", "@testing-library/react": "12.1.5", - "@types/echarts": "4.9.19", + "@types/echarts": "4.9.21", "@types/eslint": "8.44.6", "@types/jest": "26.0.24", - "@types/node": "16.18.58", + "@types/node": "16.18.61", "@types/react": "17.0.65", "@types/react-dom": "17.0.20", "@types/react-outside-click-handler": "^1.3.0", diff --git a/src/assets/blue_mobile_not_found.png b/src/assets/blue_mobile_not_found.png deleted file mode 100644 index 12a4a41cd..000000000 Binary files a/src/assets/blue_mobile_not_found.png and /dev/null differ diff --git a/src/assets/blue_not_found.png b/src/assets/blue_not_found.png deleted file mode 100644 index 77f6a3c1c..000000000 Binary files a/src/assets/blue_not_found.png and /dev/null differ diff --git a/src/assets/ckb_dark.png b/src/assets/ckb_dark.png deleted file mode 100644 index 2a7ffced3..000000000 Binary files a/src/assets/ckb_dark.png and /dev/null differ diff --git a/src/assets/ckb_transfer.png b/src/assets/ckb_transfer.png deleted file mode 100644 index 9706e8a1c..000000000 Binary files a/src/assets/ckb_transfer.png and /dev/null differ diff --git a/src/assets/copy_blue.png b/src/assets/copy_blue.png deleted file mode 100644 index f49cee74b..000000000 Binary files a/src/assets/copy_blue.png and /dev/null differ diff --git a/src/assets/copy_green.png b/src/assets/copy_green.png deleted file mode 100644 index 156d74467..000000000 Binary files a/src/assets/copy_green.png and /dev/null differ diff --git a/src/assets/current_selected.png b/src/assets/current_selected.png deleted file mode 100644 index f9336e5c4..000000000 Binary files a/src/assets/current_selected.png and /dev/null differ diff --git a/src/assets/dot_icon1.png b/src/assets/dot_icon1.png deleted file mode 100644 index b13d07985..000000000 Binary files a/src/assets/dot_icon1.png and /dev/null differ diff --git a/src/assets/dot_icon2.png b/src/assets/dot_icon2.png deleted file mode 100644 index a82ecef33..000000000 Binary files a/src/assets/dot_icon2.png and /dev/null differ diff --git a/src/assets/dot_icon3.png b/src/assets/dot_icon3.png deleted file mode 100644 index 82f85c64f..000000000 Binary files a/src/assets/dot_icon3.png and /dev/null differ diff --git a/src/assets/dropdown.png b/src/assets/dropdown.png deleted file mode 100644 index 29cbced62..000000000 Binary files a/src/assets/dropdown.png and /dev/null differ diff --git a/src/assets/home_background.svg b/src/assets/home_background.svg deleted file mode 100644 index 1c5521c5c..000000000 --- a/src/assets/home_background.svg +++ /dev/null @@ -1 +0,0 @@ -ArtboardCreated with Sketch. \ No newline at end of file diff --git a/src/assets/moon.svg b/src/assets/moon.svg deleted file mode 100644 index 44f6297c2..000000000 --- a/src/assets/moon.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/assets/moon_small.svg b/src/assets/moon_small.svg deleted file mode 100644 index 57ebe8c40..000000000 --- a/src/assets/moon_small.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/src/assets/pagination_blue_left.png b/src/assets/pagination_blue_left.png deleted file mode 100644 index 89c888ff3..000000000 Binary files a/src/assets/pagination_blue_left.png and /dev/null differ diff --git a/src/assets/pagination_blue_right.png b/src/assets/pagination_blue_right.png deleted file mode 100644 index 6884b0529..000000000 Binary files a/src/assets/pagination_blue_right.png and /dev/null differ diff --git a/src/assets/pagination_green_left.png b/src/assets/pagination_green_left.png deleted file mode 100644 index 24af7957d..000000000 Binary files a/src/assets/pagination_green_left.png and /dev/null differ diff --git a/src/assets/pagination_green_right.png b/src/assets/pagination_green_right.png deleted file mode 100644 index 45df17e34..000000000 Binary files a/src/assets/pagination_green_right.png and /dev/null differ diff --git a/src/assets/pagination_white_left.png b/src/assets/pagination_white_left.png deleted file mode 100644 index 25d398bff..000000000 Binary files a/src/assets/pagination_white_left.png and /dev/null differ diff --git a/src/assets/pagination_white_right.png b/src/assets/pagination_white_right.png deleted file mode 100644 index 63c8bd767..000000000 Binary files a/src/assets/pagination_white_right.png and /dev/null differ diff --git a/src/assets/right_grey_arrow.png b/src/assets/right_grey_arrow.png deleted file mode 100644 index 29aba8776..000000000 Binary files a/src/assets/right_grey_arrow.png and /dev/null differ diff --git a/src/assets/search_filter.png b/src/assets/search_filter.png deleted file mode 100644 index 16cbc23ef..000000000 Binary files a/src/assets/search_filter.png and /dev/null differ diff --git a/src/assets/select_dropdown.png b/src/assets/select_dropdown.png deleted file mode 100644 index 255f51d3b..000000000 Binary files a/src/assets/select_dropdown.png and /dev/null differ diff --git a/src/assets/select_dropdown_up.png b/src/assets/select_dropdown_up.png deleted file mode 100644 index 67d3eabfb..000000000 Binary files a/src/assets/select_dropdown_up.png and /dev/null differ diff --git a/src/components/Banner/HalvingBanner.tsx b/src/components/Banner/HalvingBanner.tsx index bc58cc75a..af6093662 100644 --- a/src/components/Banner/HalvingBanner.tsx +++ b/src/components/Banner/HalvingBanner.tsx @@ -1,12 +1,12 @@ import classnames from 'classnames' import { useTranslation } from 'react-i18next' import styles from './index.module.scss' -import halvingBanner from '../../assets/halving_banner.png' -import halvingBannerSuccess from '../../assets/halving_banner_success.png' -import halvingBannerSuccessMobile from '../../assets/halving_banner_success_mobile.png' -import { ReactComponent as MoveIcon } from '../../assets/move.svg' +import halvingBanner from './halving_banner.png' +import halvingBannerSuccess from './halving_banner_success.png' +import halvingBannerSuccessMobile from './halving_banner_success_mobile.png' +import { ReactComponent as MoveIcon } from './move.svg' import LoadingWhiteImage from '../../assets/loading_white.gif' -import halvingSuccessAni from '../../assets/halving_success_ani.gif' +import halvingSuccessAni from './halving_success_ani.gif' import SimpleButton from '../SimpleButton' import { useCountdown, useHalving, useIsMobile } from '../../utils/hook' diff --git a/src/assets/ckb_explorer_banner.svg b/src/components/Banner/ckb_explorer_banner.svg similarity index 100% rename from src/assets/ckb_explorer_banner.svg rename to src/components/Banner/ckb_explorer_banner.svg diff --git a/src/assets/ckb_explorer_banner_phone.svg b/src/components/Banner/ckb_explorer_banner_phone.svg similarity index 100% rename from src/assets/ckb_explorer_banner_phone.svg rename to src/components/Banner/ckb_explorer_banner_phone.svg diff --git a/src/assets/halving_banner.png b/src/components/Banner/halving_banner.png similarity index 100% rename from src/assets/halving_banner.png rename to src/components/Banner/halving_banner.png diff --git a/src/assets/halving_banner_success.png b/src/components/Banner/halving_banner_success.png similarity index 100% rename from src/assets/halving_banner_success.png rename to src/components/Banner/halving_banner_success.png diff --git a/src/assets/halving_banner_success_mobile.png b/src/components/Banner/halving_banner_success_mobile.png similarity index 100% rename from src/assets/halving_banner_success_mobile.png rename to src/components/Banner/halving_banner_success_mobile.png diff --git a/src/assets/halving_success_ani.gif b/src/components/Banner/halving_success_ani.gif similarity index 100% rename from src/assets/halving_success_ani.gif rename to src/components/Banner/halving_success_ani.gif diff --git a/src/components/Banner/index.module.scss b/src/components/Banner/index.module.scss index 2703ae03e..67da15ed9 100644 --- a/src/components/Banner/index.module.scss +++ b/src/components/Banner/index.module.scss @@ -5,13 +5,13 @@ $backgroudColor: #232323; background-color: $backgroudColor; height: 200px; position: relative; - background-image: url('../../assets/ckb_explorer_banner.svg'); + background-image: url('./ckb_explorer_banner.svg'); background-repeat: no-repeat; background-position: center center; background-size: auto 100%; @media (width <= 750px) { - background-image: url('../../assets/ckb_explorer_banner_phone.svg'); + background-image: url('./ckb_explorer_banner_phone.svg'); } } diff --git a/src/assets/move.svg b/src/components/Banner/move.svg similarity index 100% rename from src/assets/move.svg rename to src/components/Banner/move.svg diff --git a/src/assets/copy.png b/src/components/Card/HashCard/copy.png similarity index 100% rename from src/assets/copy.png rename to src/components/Card/HashCard/copy.png diff --git a/src/assets/download_tx.svg b/src/components/Card/HashCard/download_tx.svg similarity index 100% rename from src/assets/download_tx.svg rename to src/components/Card/HashCard/download_tx.svg diff --git a/src/components/Card/HashCard/index.tsx b/src/components/Card/HashCard/index.tsx index 0059ffe33..60482486c 100644 --- a/src/components/Card/HashCard/index.tsx +++ b/src/components/Card/HashCard/index.tsx @@ -3,13 +3,13 @@ import { Link } from 'react-router-dom' import { Radio, Tooltip } from 'antd' import { useTranslation } from 'react-i18next' import { LayoutLiteProfessional } from '../../../constants/common' -import CopyIcon from '../../../assets/copy.png' +import CopyIcon from './copy.png' import { explorerService } from '../../../services/ExplorerService' import SmallLoading from '../../Loading/SmallLoading' import { useIsMobile, useNewAddr, useDeprecatedAddr, useSearchParams, useUpdateSearchParams } from '../../../utils/hook' import SimpleButton from '../../SimpleButton' import { ReactComponent as OpenInNew } from '../../../assets/open_in_new.svg' -import { ReactComponent as DownloadIcon } from '../../../assets/download_tx.svg' +import { ReactComponent as DownloadIcon } from './download_tx.svg' import { HashCardPanel, LoadingPanel } from './styled' import styles from './styles.module.scss' import AddressText from '../../AddressText' diff --git a/src/assets/export_icon.svg b/src/components/CsvExport/export_icon.svg similarity index 100% rename from src/assets/export_icon.svg rename to src/components/CsvExport/export_icon.svg diff --git a/src/components/CsvExport/index.tsx b/src/components/CsvExport/index.tsx index 33fe91452..01625ee9f 100644 --- a/src/components/CsvExport/index.tsx +++ b/src/components/CsvExport/index.tsx @@ -1,7 +1,7 @@ import { Link } from 'react-router-dom' import { useTranslation } from 'react-i18next' import styles from './styles.module.scss' -import { ReactComponent as ExportIcon } from '../../assets/export_icon.svg' +import { ReactComponent as ExportIcon } from './export_icon.svg' import { SupportedExportTransactionType } from '../../services/ExplorerService' export function CsvExport({ type, id }: { type: SupportedExportTransactionType; id?: string }) { diff --git a/src/components/Error/index.tsx b/src/components/Error/index.tsx index b62c2598e..7c5986a0e 100644 --- a/src/components/Error/index.tsx +++ b/src/components/Error/index.tsx @@ -1,5 +1,5 @@ -import PCDataNotFoundImage from '../../assets/pc_data_not_found.png' -import MobileDataNotFoundImage from '../../assets/mobile_data_not_found.png' +import PCDataNotFoundImage from './pc_data_not_found.png' +import MobileDataNotFoundImage from './mobile_data_not_found.png' import { useIsMobile } from '../../utils/hook' import { ErrorPanel } from './styled' diff --git a/src/assets/mobile_data_not_found.png b/src/components/Error/mobile_data_not_found.png similarity index 100% rename from src/assets/mobile_data_not_found.png rename to src/components/Error/mobile_data_not_found.png diff --git a/src/assets/pc_data_not_found.png b/src/components/Error/pc_data_not_found.png similarity index 100% rename from src/assets/pc_data_not_found.png rename to src/components/Error/pc_data_not_found.png diff --git a/src/assets/footer_X.svg b/src/components/Footer/footer_X.svg similarity index 100% rename from src/assets/footer_X.svg rename to src/components/Footer/footer_X.svg diff --git a/src/assets/footer_discord.svg b/src/components/Footer/footer_discord.svg similarity index 100% rename from src/assets/footer_discord.svg rename to src/components/Footer/footer_discord.svg diff --git a/src/assets/footer_forum.svg b/src/components/Footer/footer_forum.svg similarity index 100% rename from src/assets/footer_forum.svg rename to src/components/Footer/footer_forum.svg diff --git a/src/assets/footer_medium.svg b/src/components/Footer/footer_medium.svg similarity index 100% rename from src/assets/footer_medium.svg rename to src/components/Footer/footer_medium.svg diff --git a/src/assets/footer_reddit.svg b/src/components/Footer/footer_reddit.svg similarity index 100% rename from src/assets/footer_reddit.svg rename to src/components/Footer/footer_reddit.svg diff --git a/src/assets/footer_telegram.svg b/src/components/Footer/footer_telegram.svg similarity index 100% rename from src/assets/footer_telegram.svg rename to src/components/Footer/footer_telegram.svg diff --git a/src/assets/footer_youtube.svg b/src/components/Footer/footer_youtube.svg similarity index 100% rename from src/assets/footer_youtube.svg rename to src/components/Footer/footer_youtube.svg diff --git a/src/components/Footer/index.tsx b/src/components/Footer/index.tsx index d6944fdc2..814eac3ba 100644 --- a/src/components/Footer/index.tsx +++ b/src/components/Footer/index.tsx @@ -1,12 +1,12 @@ import { ReactNode, memo, useMemo } from 'react' import { useTranslation } from 'react-i18next' -import { ReactComponent as XIcon } from '../../assets/footer_X.svg' -import { ReactComponent as MediumIcon } from '../../assets/footer_medium.svg' -import { ReactComponent as TelegramIcon } from '../../assets/footer_telegram.svg' -import { ReactComponent as RedditIcon } from '../../assets/footer_reddit.svg' -import { ReactComponent as YoutubeIcon } from '../../assets/footer_youtube.svg' -import { ReactComponent as ForumIcon } from '../../assets/footer_forum.svg' -import { ReactComponent as Discord } from '../../assets/footer_discord.svg' +import { ReactComponent as XIcon } from './footer_X.svg' +import { ReactComponent as MediumIcon } from './footer_medium.svg' +import { ReactComponent as TelegramIcon } from './footer_telegram.svg' +import { ReactComponent as RedditIcon } from './footer_reddit.svg' +import { ReactComponent as YoutubeIcon } from './footer_youtube.svg' +import { ReactComponent as ForumIcon } from './footer_forum.svg' +import { ReactComponent as Discord } from './footer_discord.svg' import { getCurrentYear } from '../../utils/date' import { FooterMenuPanel, FooterItemPanel, FooterImageItemPanel, FooterPanel } from './styled' import { useIsMobile } from '../../utils/hook' diff --git a/src/components/Header/LanguageComp/index.tsx b/src/components/Header/LanguageComp/index.tsx index 22fbc17f9..3fc149677 100644 --- a/src/components/Header/LanguageComp/index.tsx +++ b/src/components/Header/LanguageComp/index.tsx @@ -2,7 +2,7 @@ import { useState, useLayoutEffect, FC } from 'react' import { HeaderLanguagePanel, MobileSubMenuPanel } from './styled' import SimpleButton from '../../SimpleButton' import WhiteDropdownIcon from '../../../assets/white_dropdown.png' -import WhiteDropUpIcon from '../../../assets/white_drop_up.png' +import WhiteDropUpIcon from './white_drop_up.png' import BlueDropUpIcon from '../../../assets/blue_drop_up.png' import GreenDropUpIcon from '../../../assets/green_drop_up.png' import { isMainnet } from '../../../utils/chain' diff --git a/src/assets/white_drop_up.png b/src/components/Header/LanguageComp/white_drop_up.png similarity index 100% rename from src/assets/white_drop_up.png rename to src/components/Header/LanguageComp/white_drop_up.png diff --git a/src/components/Header/SearchComp/index.tsx b/src/components/Header/SearchComp/index.tsx index 5b0a4c623..ee6f0d35a 100644 --- a/src/components/Header/SearchComp/index.tsx +++ b/src/components/Header/SearchComp/index.tsx @@ -1,6 +1,6 @@ import { FC, memo, useCallback } from 'react' import Search from '../../Search' -import SearchLogo from '../../../assets/search_white.png' +import SearchLogo from './search_white.png' import { HeaderSearchPanel, HeaderSearchBarPanel } from './styled' export const SearchComp: FC<{ diff --git a/src/assets/search_white.png b/src/components/Header/SearchComp/search_white.png similarity index 100% rename from src/assets/search_white.png rename to src/components/Header/SearchComp/search_white.png diff --git a/src/assets/ckb_logo.png b/src/components/Header/ckb_logo.png similarity index 100% rename from src/assets/ckb_logo.png rename to src/components/Header/ckb_logo.png diff --git a/src/components/Header/index.tsx b/src/components/Header/index.tsx index fc7c95ca6..fc4e40155 100644 --- a/src/components/Header/index.tsx +++ b/src/components/Header/index.tsx @@ -2,7 +2,7 @@ import { FC, ReactNode, useEffect, useRef, useState } from 'react' import { useLocation } from 'react-router' import classNames from 'classnames' import { createBrowserHistory } from 'history' -import LogoIcon from '../../assets/ckb_logo.png' +import LogoIcon from './ckb_logo.png' import { HeaderPanel, HeaderEmptyPanel, HeaderMobileMenuPanel, HeaderLogoPanel } from './styled' import MenusComp from './MenusComp' import { SearchComp } from './SearchComp' diff --git a/src/components/Pagination/index.tsx b/src/components/Pagination/index.tsx index e828f5e55..39b2ac84d 100644 --- a/src/components/Pagination/index.tsx +++ b/src/components/Pagination/index.tsx @@ -1,10 +1,10 @@ import { useState } from 'react' import { useTranslation } from 'react-i18next' import { PaginationLeftItem, PaginationRightItem, PaginationPanel } from './styled' -import LeftBlack from '../../assets/pagination_black_left.png' -import RightBlack from '../../assets/pagination_black_right.png' -import LeftGrey from '../../assets/pagination_grey_left.png' -import RightGrey from '../../assets/pagination_grey_right.png' +import LeftBlack from './pagination_black_left.png' +import RightBlack from './pagination_black_right.png' +import LeftGrey from './pagination_grey_left.png' +import RightGrey from './pagination_grey_right.png' import { useIsMobile } from '../../utils/hook' import SimpleButton from '../SimpleButton' import { HelpTip } from '../HelpTip' diff --git a/src/assets/pagination_black_left.png b/src/components/Pagination/pagination_black_left.png similarity index 100% rename from src/assets/pagination_black_left.png rename to src/components/Pagination/pagination_black_left.png diff --git a/src/assets/pagination_black_right.png b/src/components/Pagination/pagination_black_right.png similarity index 100% rename from src/assets/pagination_black_right.png rename to src/components/Pagination/pagination_black_right.png diff --git a/src/assets/pagination_grey_left.png b/src/components/Pagination/pagination_grey_left.png similarity index 100% rename from src/assets/pagination_grey_left.png rename to src/components/Pagination/pagination_grey_left.png diff --git a/src/assets/pagination_grey_right.png b/src/components/Pagination/pagination_grey_right.png similarity index 100% rename from src/assets/pagination_grey_right.png rename to src/components/Pagination/pagination_grey_right.png diff --git a/src/components/Transaction/TransactionCellArrow/index.tsx b/src/components/Transaction/TransactionCellArrow/index.tsx index 47fd63e41..589ff7261 100644 --- a/src/components/Transaction/TransactionCellArrow/index.tsx +++ b/src/components/Transaction/TransactionCellArrow/index.tsx @@ -2,10 +2,10 @@ import { Link } from 'react-router-dom' import { Tooltip } from 'antd' import { useTranslation } from 'react-i18next' import { CellType } from '../../../constants/common' -import RightGreenArrow from '../../../assets/right_green_arrow.png' -import RightBlueArrow from '../../../assets/right_blue_arrow.png' -import LiveCellIcon from '../../../assets/live_cell.png' -import LiveCellBlueIcon from '../../../assets/live_cell_blue.png' +import RightGreenArrow from './right_green_arrow.png' +import RightBlueArrow from './right_blue_arrow.png' +import LiveCellIcon from './live_cell.png' +import LiveCellBlueIcon from './live_cell_blue.png' import { isMainnet } from '../../../utils/chain' import { RightArrowImage, LeftArrowImage } from './styled' import { Cell } from '../../../models/Cell' diff --git a/src/assets/live_cell.png b/src/components/Transaction/TransactionCellArrow/live_cell.png similarity index 100% rename from src/assets/live_cell.png rename to src/components/Transaction/TransactionCellArrow/live_cell.png diff --git a/src/assets/live_cell_blue.png b/src/components/Transaction/TransactionCellArrow/live_cell_blue.png similarity index 100% rename from src/assets/live_cell_blue.png rename to src/components/Transaction/TransactionCellArrow/live_cell_blue.png diff --git a/src/assets/right_blue_arrow.png b/src/components/Transaction/TransactionCellArrow/right_blue_arrow.png similarity index 100% rename from src/assets/right_blue_arrow.png rename to src/components/Transaction/TransactionCellArrow/right_blue_arrow.png diff --git a/src/assets/right_green_arrow.png b/src/components/Transaction/TransactionCellArrow/right_green_arrow.png similarity index 100% rename from src/assets/right_green_arrow.png rename to src/components/Transaction/TransactionCellArrow/right_green_arrow.png diff --git a/src/components/TransactionItem/index.tsx b/src/components/TransactionItem/index.tsx index aedcc2514..6448d9a5b 100644 --- a/src/components/TransactionItem/index.tsx +++ b/src/components/TransactionItem/index.tsx @@ -1,7 +1,7 @@ import { ReactNode, useEffect, useRef } from 'react' import { useTranslation } from 'react-i18next' -import RightArrowIcon from '../../assets/input_arrow_output.png' -import DownArrowIcon from '../../assets/input_arrow_output_down.png' +import RightArrowIcon from './input_arrow_output.png' +import DownArrowIcon from './input_arrow_output_down.png' import { localeNumberString } from '../../utils/number' import TransactionCell from './TransactionItemCell' import TransactionCellList from './TransactionItemCellList' diff --git a/src/assets/input_arrow_output.png b/src/components/TransactionItem/input_arrow_output.png similarity index 100% rename from src/assets/input_arrow_output.png rename to src/components/TransactionItem/input_arrow_output.png diff --git a/src/assets/input_arrow_output_down.png b/src/components/TransactionItem/input_arrow_output_down.png similarity index 100% rename from src/assets/input_arrow_output_down.png rename to src/components/TransactionItem/input_arrow_output_down.png diff --git a/src/assets/blue_mobile_404.png b/src/pages/404/blue_mobile_404.png similarity index 100% rename from src/assets/blue_mobile_404.png rename to src/pages/404/blue_mobile_404.png diff --git a/src/assets/blue_pc_404.png b/src/pages/404/blue_pc_404.png similarity index 100% rename from src/assets/blue_pc_404.png rename to src/pages/404/blue_pc_404.png diff --git a/src/pages/404/index.tsx b/src/pages/404/index.tsx index 42d9a84f8..ef5f8219e 100644 --- a/src/pages/404/index.tsx +++ b/src/pages/404/index.tsx @@ -1,7 +1,7 @@ -import PC404mage from '../../assets/pc_404.png' -import Mobile404Image from '../../assets/mobile_404.png' -import PCBlue404Image from '../../assets/blue_pc_404.png' -import MobileBlue404Image from '../../assets/blue_mobile_404.png' +import PC404mage from './pc_404.png' +import Mobile404Image from './mobile_404.png' +import PCBlue404Image from './blue_pc_404.png' +import MobileBlue404Image from './blue_mobile_404.png' import { useIsMobile } from '../../utils/hook' import { isMainnet } from '../../utils/chain' import styles from './index.module.scss' diff --git a/src/assets/mobile_404.png b/src/pages/404/mobile_404.png similarity index 100% rename from src/assets/mobile_404.png rename to src/pages/404/mobile_404.png diff --git a/src/assets/pc_404.png b/src/pages/404/pc_404.png similarity index 100% rename from src/assets/pc_404.png rename to src/pages/404/pc_404.png diff --git a/src/pages/Address/AddressComp.tsx b/src/pages/Address/AddressComp.tsx index 63d1d0b64..3afe3f739 100644 --- a/src/pages/Address/AddressComp.tsx +++ b/src/pages/Address/AddressComp.tsx @@ -20,10 +20,10 @@ import { } from './styled' import DecimalCapacity from '../../components/DecimalCapacity' import TitleCard from '../../components/Card/TitleCard' -import CKBTokenIcon from '../../assets/ckb_token_icon.png' +import CKBTokenIcon from './ckb_token_icon.png' import SUDTTokenIcon from '../../assets/sudt_token.png' -import { ReactComponent as TimeDownIcon } from '../../assets/time_down.svg' -import { ReactComponent as TimeUpIcon } from '../../assets/time_up.svg' +import { ReactComponent as TimeDownIcon } from './time_down.svg' +import { ReactComponent as TimeUpIcon } from './time_up.svg' import { sliceNftName } from '../../utils/string' import { OrderByType, diff --git a/src/assets/ckb_token_icon.png b/src/pages/Address/ckb_token_icon.png similarity index 100% rename from src/assets/ckb_token_icon.png rename to src/pages/Address/ckb_token_icon.png diff --git a/src/assets/time_down.svg b/src/pages/Address/time_down.svg similarity index 100% rename from src/assets/time_down.svg rename to src/pages/Address/time_down.svg diff --git a/src/assets/time_up.svg b/src/pages/Address/time_up.svg similarity index 100% rename from src/assets/time_up.svg rename to src/pages/Address/time_up.svg diff --git a/src/pages/BlockDetail/BlockComp.tsx b/src/pages/BlockDetail/BlockComp.tsx index 1d0c9e361..a78a3dfb5 100644 --- a/src/pages/BlockDetail/BlockComp.tsx +++ b/src/pages/BlockDetail/BlockComp.tsx @@ -4,10 +4,10 @@ import BigNumber from 'bignumber.js' import { Tooltip } from 'antd' import { Trans, useTranslation } from 'react-i18next' import Pagination from '../../components/Pagination' -import DropDownIcon from '../../assets/content_drop_down.png' -import PackUpIcon from '../../assets/content_pack_up.png' -import DropDownBlueIcon from '../../assets/content_blue_drop_down.png' -import PackUpBlueIcon from '../../assets/content_blue_pack_up.png' +import DropDownIcon from './content_drop_down.png' +import PackUpIcon from './content_pack_up.png' +import DropDownBlueIcon from './content_blue_drop_down.png' +import PackUpBlueIcon from './content_blue_pack_up.png' import OverviewCard, { OverviewItemData } from '../../components/Card/OverviewCard' import TransactionItem from '../../components/TransactionItem/index' import { parseSimpleDate } from '../../utils/date' @@ -26,8 +26,8 @@ import { } from './styled' import HelpIcon from '../../assets/qa_help.png' import MoreIcon from '../../assets/more.png' -import MinerRewardIcon from '../../assets/miner_complete.png' -import { ReactComponent as LeftArrow } from '../../assets/prev_block.svg' +import MinerRewardIcon from './miner_complete.png' +import { ReactComponent as LeftArrow } from './prev_block.svg' import { isMainnet } from '../../utils/chain' import DecimalCapacity from '../../components/DecimalCapacity' import { DELAY_BLOCK_NUMBER } from '../../constants/common' diff --git a/src/assets/content_blue_drop_down.png b/src/pages/BlockDetail/content_blue_drop_down.png similarity index 100% rename from src/assets/content_blue_drop_down.png rename to src/pages/BlockDetail/content_blue_drop_down.png diff --git a/src/assets/content_blue_pack_up.png b/src/pages/BlockDetail/content_blue_pack_up.png similarity index 100% rename from src/assets/content_blue_pack_up.png rename to src/pages/BlockDetail/content_blue_pack_up.png diff --git a/src/assets/content_drop_down.png b/src/pages/BlockDetail/content_drop_down.png similarity index 100% rename from src/assets/content_drop_down.png rename to src/pages/BlockDetail/content_drop_down.png diff --git a/src/assets/content_pack_up.png b/src/pages/BlockDetail/content_pack_up.png similarity index 100% rename from src/assets/content_pack_up.png rename to src/pages/BlockDetail/content_pack_up.png diff --git a/src/assets/miner_complete.png b/src/pages/BlockDetail/miner_complete.png similarity index 100% rename from src/assets/miner_complete.png rename to src/pages/BlockDetail/miner_complete.png diff --git a/src/assets/prev_block.svg b/src/pages/BlockDetail/prev_block.svg similarity index 100% rename from src/assets/prev_block.svg rename to src/pages/BlockDetail/prev_block.svg diff --git a/src/assets/Mobile_error.png b/src/pages/Error/Mobile_error.png similarity index 100% rename from src/assets/Mobile_error.png rename to src/pages/Error/Mobile_error.png diff --git a/src/assets/error.png b/src/pages/Error/error.png similarity index 100% rename from src/assets/error.png rename to src/pages/Error/error.png diff --git a/src/pages/Error/index.tsx b/src/pages/Error/index.tsx index fd5e38ec2..67671668f 100644 --- a/src/pages/Error/index.tsx +++ b/src/pages/Error/index.tsx @@ -1,7 +1,7 @@ import { useTranslation } from 'react-i18next' import Content from '../../components/Content' -import PCErrorImage from '../../assets/error.png' -import MobileErrorImage from '../../assets/Mobile_error.png' +import PCErrorImage from './error.png' +import MobileErrorImage from './Mobile_error.png' import { useIsMobile } from '../../utils/hook' import styles from './index.module.scss' diff --git a/src/assets/block_icon.svg b/src/pages/ExportTransactions/block_icon.svg similarity index 100% rename from src/assets/block_icon.svg rename to src/pages/ExportTransactions/block_icon.svg diff --git a/src/assets/error_icon.svg b/src/pages/ExportTransactions/error_icon.svg similarity index 100% rename from src/assets/error_icon.svg rename to src/pages/ExportTransactions/error_icon.svg diff --git a/src/pages/ExportTransactions/index.tsx b/src/pages/ExportTransactions/index.tsx index ad4986544..319fe3baf 100644 --- a/src/pages/ExportTransactions/index.tsx +++ b/src/pages/ExportTransactions/index.tsx @@ -11,9 +11,9 @@ import Content from '../../components/Content' import styles from './styles.module.scss' import 'dayjs/locale/es-us' import 'dayjs/locale/zh-cn' -import { ReactComponent as BlockIcon } from '../../assets/block_icon.svg' -import { ReactComponent as ErrorIcon } from '../../assets/error_icon.svg' -import { ReactComponent as SuccessIcon } from '../../assets/success_icon.svg' +import { ReactComponent as BlockIcon } from './block_icon.svg' +import { ReactComponent as ErrorIcon } from './error_icon.svg' +import { ReactComponent as SuccessIcon } from './success_icon.svg' import { omit } from '../../utils/object' import { SupportedExportTransactionType, explorerService } from '../../services/ExplorerService' diff --git a/src/assets/success_icon.svg b/src/pages/ExportTransactions/success_icon.svg similarity index 100% rename from src/assets/success_icon.svg rename to src/pages/ExportTransactions/success_icon.svg diff --git a/src/pages/FeeRateTracker/FeeRateTrackerComp.tsx b/src/pages/FeeRateTracker/FeeRateTrackerComp.tsx index ffb8f0f1e..da9e84933 100644 --- a/src/pages/FeeRateTracker/FeeRateTrackerComp.tsx +++ b/src/pages/FeeRateTracker/FeeRateTrackerComp.tsx @@ -5,9 +5,9 @@ import classNames from 'classnames' import { useTranslation } from 'react-i18next' import styles from './styles.module.scss' import { ReactChartCore } from '../StatisticsChart/common' -import { ReactComponent as BikeIcon } from '../../assets/bike.svg' -import { ReactComponent as CarIcon } from '../../assets/car.svg' -import { ReactComponent as RocketIcon } from '../../assets/rocket.svg' +import { ReactComponent as BikeIcon } from './bike.svg' +import { ReactComponent as CarIcon } from './car.svg' +import { ReactComponent as RocketIcon } from './rocket.svg' import { ChartColor } from '../../constants/common' import { useCurrentLanguage } from '../../utils/i18n' import type { FeeRateTracker } from '../../services/ExplorerService/fetcher' diff --git a/src/assets/bike.svg b/src/pages/FeeRateTracker/bike.svg similarity index 100% rename from src/assets/bike.svg rename to src/pages/FeeRateTracker/bike.svg diff --git a/src/assets/car.svg b/src/pages/FeeRateTracker/car.svg similarity index 100% rename from src/assets/car.svg rename to src/pages/FeeRateTracker/car.svg diff --git a/src/assets/rocket.svg b/src/pages/FeeRateTracker/rocket.svg similarity index 100% rename from src/assets/rocket.svg rename to src/pages/FeeRateTracker/rocket.svg diff --git a/src/assets/X.svg b/src/pages/Halving/X.svg similarity index 100% rename from src/assets/X.svg rename to src/pages/Halving/X.svg diff --git a/src/assets/block-rewards-cn.png b/src/pages/Halving/block-rewards-cn.png similarity index 100% rename from src/assets/block-rewards-cn.png rename to src/pages/Halving/block-rewards-cn.png diff --git a/src/assets/block-rewards.png b/src/pages/Halving/block-rewards.png similarity index 100% rename from src/assets/block-rewards.png rename to src/pages/Halving/block-rewards.png diff --git a/src/assets/calendar.svg b/src/pages/Halving/calendar.svg similarity index 100% rename from src/assets/calendar.svg rename to src/pages/Halving/calendar.svg diff --git a/src/assets/ckb_base_issuance_trend.png b/src/pages/Halving/ckb_base_issuance_trend.png similarity index 100% rename from src/assets/ckb_base_issuance_trend.png rename to src/pages/Halving/ckb_base_issuance_trend.png diff --git a/src/assets/halving_bg.png b/src/pages/Halving/halving_bg.png similarity index 100% rename from src/assets/halving_bg.png rename to src/pages/Halving/halving_bg.png diff --git a/src/assets/halving_success_bg.png b/src/pages/Halving/halving_success_bg.png similarity index 100% rename from src/assets/halving_success_bg.png rename to src/pages/Halving/halving_success_bg.png diff --git a/src/pages/Halving/index.tsx b/src/pages/Halving/index.tsx index 7cad229a4..26c9784dd 100644 --- a/src/pages/Halving/index.tsx +++ b/src/pages/Halving/index.tsx @@ -3,13 +3,13 @@ import BigNumber from 'bignumber.js' import classnames from 'classnames' import { useTranslation } from 'react-i18next' import Content from '../../components/Content' -import baseIssuance from '../../assets/ckb_base_issuance_trend.png' -import blockRewards from '../../assets/block-rewards.png' -import blockRewardsCN from '../../assets/block-rewards-cn.png' -import halvingBg from '../../assets/halving_bg.png' -import halvingSuccessBg from '../../assets/halving_success_bg.png' -import { ReactComponent as CalendarIcon } from '../../assets/calendar.svg' -import { ReactComponent as XIcon } from '../../assets/X.svg' +import baseIssuance from './ckb_base_issuance_trend.png' +import blockRewards from './block-rewards.png' +import blockRewardsCN from './block-rewards-cn.png' +import halvingBg from './halving_bg.png' +import halvingSuccessBg from './halving_success_bg.png' +import { ReactComponent as CalendarIcon } from './calendar.svg' +import { ReactComponent as XIcon } from './X.svg' import { ReactComponent as WarningCircle } from '../../assets/warning_circle.svg' import { HalvingTable } from './HalvingTable' import { HalvingInfo } from './HalvingInfo' diff --git a/src/pages/Home/AverageBlockTimeChart/index.tsx b/src/pages/Home/AverageBlockTimeChart/index.tsx index 261c9899b..f338ea72a 100644 --- a/src/pages/Home/AverageBlockTimeChart/index.tsx +++ b/src/pages/Home/AverageBlockTimeChart/index.tsx @@ -3,15 +3,15 @@ import 'echarts/lib/chart/line' import 'echarts/lib/component/title' import echarts from 'echarts/lib/echarts' import { useTranslation } from 'react-i18next' +import { useQuery } from '@tanstack/react-query' import { parseDateNoTime } from '../../../utils/date' import { localeNumberString } from '../../../utils/number' import SmallLoading from '../../../components/Loading/SmallLoading' import { HomeChartLink, ChartLoadingPanel } from './styled' import ChartNoDataImage from '../../../assets/chart_no_data_white.png' -import { useChartQueryWithCache, useIsLGScreen } from '../../../utils/hook' +import { useIsLGScreen } from '../../../utils/hook' import { ChartItem, explorerService } from '../../../services/ExplorerService' import { ReactChartCore } from '../../StatisticsChart/common' -import { AverageBlockTimeCacheKey } from '../../StatisticsChart/block/AverageBlockTime' const useOption = () => { const { t } = useTranslation() @@ -109,10 +109,12 @@ export default memo(() => { const isLG = useIsLGScreen() const parseOption = useOption() - const query = useChartQueryWithCache( - explorerService.api.fetchStatisticAverageBlockTimes, - AverageBlockTimeCacheKey, - 'date', + const query = useQuery( + ['fetchStatisticAverageBlockTimes'], + () => explorerService.api.fetchStatisticAverageBlockTimes(), + { + refetchOnWindowFocus: false, + }, ) const fullStatisticAverageBlockTimes = useMemo(() => query.data ?? [], [query.data]) diff --git a/src/pages/Home/HashRateChart/index.tsx b/src/pages/Home/HashRateChart/index.tsx index e67d068cd..21f3d46b0 100644 --- a/src/pages/Home/HashRateChart/index.tsx +++ b/src/pages/Home/HashRateChart/index.tsx @@ -4,15 +4,15 @@ import 'echarts/lib/chart/line' import 'echarts/lib/component/title' import echarts from 'echarts/lib/echarts' import { useTranslation } from 'react-i18next' +import { useQuery } from '@tanstack/react-query' import { handleAxis } from '../../../utils/chart' import { parseDateNoTime } from '../../../utils/date' import SmallLoading from '../../../components/Loading/SmallLoading' import { HomeChartLink, ChartLoadingPanel } from './styled' import ChartNoDataImage from '../../../assets/chart_no_data_white.png' -import { useChartQueryWithCache, useIsLGScreen } from '../../../utils/hook' +import { useIsLGScreen } from '../../../utils/hook' import { ChartItem, explorerService } from '../../../services/ExplorerService' import { ReactChartCore } from '../../StatisticsChart/common' -import { HashRateCacheKey } from '../../StatisticsChart/mining/HashRate' const useOption = () => { const { t } = useTranslation() @@ -103,7 +103,9 @@ const useOption = () => { } export default memo(() => { const isLG = useIsLGScreen() - const query = useChartQueryWithCache(explorerService.api.fetchStatisticHashRate, HashRateCacheKey, 'date') + const query = useQuery(['fetchStatisticHashRate'], () => explorerService.api.fetchStatisticHashRate(), { + refetchOnWindowFocus: false, + }) const fullStatisticHashRates = useMemo(() => query.data ?? [], [query.data]) const parseOption = useOption() diff --git a/src/pages/Home/index.tsx b/src/pages/Home/index.tsx index 00e14ce74..938c83d2d 100644 --- a/src/pages/Home/index.tsx +++ b/src/pages/Home/index.tsx @@ -18,8 +18,8 @@ import { BLOCK_POLLING_TIME, ListPageParams, DELAY_BLOCK_NUMBER } from '../../co import { localeNumberString, handleHashRate, handleDifficulty } from '../../utils/number' import { handleBigNumber } from '../../utils/string' import { isMainnet } from '../../utils/chain' -import LatestBlocksIcon from '../../assets/latest_blocks.png' -import LatestTransactionsIcon from '../../assets/latest_transactions.png' +import LatestBlocksIcon from './latest_blocks.png' +import LatestTransactionsIcon from './latest_transactions.png' import { BlockCardItem, TransactionCardItem } from './TableCard' import Loading from '../../components/Loading/SmallLoading' import { useElementIntersecting, useIsLGScreen, useIsMobile } from '../../utils/hook' diff --git a/src/assets/latest_blocks.png b/src/pages/Home/latest_blocks.png similarity index 100% rename from src/assets/latest_blocks.png rename to src/pages/Home/latest_blocks.png diff --git a/src/assets/latest_transactions.png b/src/pages/Home/latest_transactions.png similarity index 100% rename from src/assets/latest_transactions.png rename to src/pages/Home/latest_transactions.png diff --git a/src/assets/dao_balance.png b/src/pages/NervosDao/DaoOverview/dao_balance.png similarity index 100% rename from src/assets/dao_balance.png rename to src/pages/NervosDao/DaoOverview/dao_balance.png diff --git a/src/assets/dao_down.png b/src/pages/NervosDao/DaoOverview/dao_down.png similarity index 100% rename from src/assets/dao_down.png rename to src/pages/NervosDao/DaoOverview/dao_down.png diff --git a/src/assets/dao_up.png b/src/pages/NervosDao/DaoOverview/dao_up.png similarity index 100% rename from src/assets/dao_up.png rename to src/pages/NervosDao/DaoOverview/dao_up.png diff --git a/src/pages/NervosDao/DaoOverview/index.tsx b/src/pages/NervosDao/DaoOverview/index.tsx index 546c161cf..fda5ed3b3 100644 --- a/src/pages/NervosDao/DaoOverview/index.tsx +++ b/src/pages/NervosDao/DaoOverview/index.tsx @@ -17,9 +17,9 @@ import { DaoOverviewPieChartPanel, DaoOverviewPieItemsPanel, } from './styled' -import DaoUpIcon from '../../../assets/dao_up.png' -import DaoDownIcon from '../../../assets/dao_down.png' -import DaoBalanceIcon from '../../../assets/dao_balance.png' +import DaoUpIcon from './dao_up.png' +import DaoDownIcon from './dao_down.png' +import DaoBalanceIcon from './dao_balance.png' import { handleBigNumber, handleBigNumberFloor } from '../../../utils/string' import { localeNumberString } from '../../../utils/number' import { shannonToCkbDecimal, shannonToCkb } from '../../../utils/util' diff --git a/src/pages/Script/ScriptsComp.tsx b/src/pages/Script/ScriptsComp.tsx index ec0720bf9..a1224b8b3 100644 --- a/src/pages/Script/ScriptsComp.tsx +++ b/src/pages/Script/ScriptsComp.tsx @@ -18,7 +18,7 @@ import styles from './styles.module.scss' import { QueryResult } from '../../components/QueryResult' import AddressText from '../../components/AddressText' import { ReactComponent as CopyIcon } from '../../assets/copy_icon.svg' -import { ReactComponent as InfoMoreIcon } from '../../assets/info_more_icon.svg' +import { ReactComponent as InfoMoreIcon } from './info_more_icon.svg' import { useSetToast } from '../../components/Toast' import { CellBasicInfo, transformToTransaction } from '../../utils/transformer' diff --git a/src/assets/info_more_icon.svg b/src/pages/Script/info_more_icon.svg similarity index 100% rename from src/assets/info_more_icon.svg rename to src/pages/Script/info_more_icon.svg diff --git a/src/pages/StatisticsChart/activities/AddressBalanceRank.tsx b/src/pages/StatisticsChart/activities/AddressBalanceRank.tsx index c50ce3647..488d0e173 100644 --- a/src/pages/StatisticsChart/activities/AddressBalanceRank.tsx +++ b/src/pages/StatisticsChart/activities/AddressBalanceRank.tsx @@ -143,8 +143,7 @@ export const AddressBalanceRankChart = ({ isThumbnail = false }: { isThumbnail?: onFetched={setStatisticAddressBalanceRanks} getEChartOption={getEChartOption} toCSV={toCSV} - cacheKey="AddressBalanceRank" - cacheMode="date" + queryKey="fetchStatisticAddressBalanceRank" /> ) } diff --git a/src/pages/StatisticsChart/activities/AddressCount.tsx b/src/pages/StatisticsChart/activities/AddressCount.tsx index 31e0393d2..90f35e522 100644 --- a/src/pages/StatisticsChart/activities/AddressCount.tsx +++ b/src/pages/StatisticsChart/activities/AddressCount.tsx @@ -108,8 +108,7 @@ export const AddressCountChart = ({ isThumbnail = false }: { isThumbnail?: boole fetchData={explorerService.api.fetchStatisticAddressCount} getEChartOption={useOption} toCSV={toCSV} - cacheKey="AddressCount" - cacheMode="date" + queryKey="fetchStatisticAddressCount" /> ) } diff --git a/src/pages/StatisticsChart/activities/BalanceDistribution.tsx b/src/pages/StatisticsChart/activities/BalanceDistribution.tsx index a003f2a47..f1ac41ba4 100644 --- a/src/pages/StatisticsChart/activities/BalanceDistribution.tsx +++ b/src/pages/StatisticsChart/activities/BalanceDistribution.tsx @@ -187,8 +187,7 @@ export const BalanceDistributionChart = ({ isThumbnail = false }: { isThumbnail? fetchData={explorerService.api.fetchStatisticBalanceDistribution} getEChartOption={useOption} toCSV={toCSV} - cacheKey="BalanceDistribution" - cacheMode="date" + queryKey="fetchStatisticBalanceDistribution" /> ) } diff --git a/src/pages/StatisticsChart/activities/CellCount.tsx b/src/pages/StatisticsChart/activities/CellCount.tsx index d65638888..d42a75093 100644 --- a/src/pages/StatisticsChart/activities/CellCount.tsx +++ b/src/pages/StatisticsChart/activities/CellCount.tsx @@ -194,8 +194,7 @@ export const CellCountChart = ({ isThumbnail = false }: { isThumbnail?: boolean fetchData={explorerService.api.fetchStatisticCellCount} getEChartOption={useOption} toCSV={toCSV} - cacheKey="CellCount" - cacheMode="date" + queryKey="fetchStatisticCellCount" /> ) } diff --git a/src/pages/StatisticsChart/activities/TransactionCount.tsx b/src/pages/StatisticsChart/activities/TransactionCount.tsx index f85e99713..c5f831849 100644 --- a/src/pages/StatisticsChart/activities/TransactionCount.tsx +++ b/src/pages/StatisticsChart/activities/TransactionCount.tsx @@ -106,8 +106,7 @@ export const TransactionCountChart = ({ isThumbnail = false }: { isThumbnail?: b fetchData={explorerService.api.fetchStatisticTransactionCount} getEChartOption={useOption} toCSV={toCSV} - cacheKey="TransactionCount" - cacheMode="date" + queryKey="fetchStatisticTransactionCount" /> ) } diff --git a/src/pages/StatisticsChart/activities/TxFeeHistory.tsx b/src/pages/StatisticsChart/activities/TxFeeHistory.tsx index aa7edaddd..d2c2682c5 100644 --- a/src/pages/StatisticsChart/activities/TxFeeHistory.tsx +++ b/src/pages/StatisticsChart/activities/TxFeeHistory.tsx @@ -112,8 +112,7 @@ export const TxFeeHistoryChart = ({ isThumbnail = false }: { isThumbnail?: boole fetchData={explorerService.api.fetchStatisticTxFeeHistory} getEChartOption={useOption} toCSV={toCSV} - cacheKey="TransactionFee" - cacheMode="date" + queryKey="fetchStatisticTxFeeHistory" /> ) } diff --git a/src/pages/StatisticsChart/block/AverageBlockTime.tsx b/src/pages/StatisticsChart/block/AverageBlockTime.tsx index 1b72c92e6..4baa619dc 100644 --- a/src/pages/StatisticsChart/block/AverageBlockTime.tsx +++ b/src/pages/StatisticsChart/block/AverageBlockTime.tsx @@ -7,8 +7,6 @@ import { ChartItem, explorerService } from '../../../services/ExplorerService' import { useCurrentLanguage } from '../../../utils/i18n' import { ChartColorConfig } from '../../../constants/common' -export const AverageBlockTimeCacheKey = 'AverageBlockTime' - const useOption = ( statisticAverageBlockTimes: ChartItem.AverageBlockTime[], chartColor: ChartColorConfig, @@ -183,8 +181,7 @@ export const AverageBlockTimeChart = ({ isThumbnail = false }: { isThumbnail?: b fetchData={explorerService.api.fetchStatisticAverageBlockTimes} getEChartOption={useOption} toCSV={toCSV} - cacheKey={AverageBlockTimeCacheKey} - cacheMode="date" + queryKey="fetchStatisticAverageBlockTimes" /> ) } diff --git a/src/pages/StatisticsChart/block/BlockTimeDistribution.tsx b/src/pages/StatisticsChart/block/BlockTimeDistribution.tsx index f017e0648..135259e4c 100644 --- a/src/pages/StatisticsChart/block/BlockTimeDistribution.tsx +++ b/src/pages/StatisticsChart/block/BlockTimeDistribution.tsx @@ -104,8 +104,7 @@ export const BlockTimeDistributionChart = ({ isThumbnail = false }: { isThumbnai fetchData={explorerService.api.fetchStatisticBlockTimeDistribution} getEChartOption={useOption} toCSV={toCSV} - cacheKey="BlockTimeDistribution" - cacheMode="date" + queryKey="fetchStatisticBlockTimeDistribution" /> ) } diff --git a/src/pages/StatisticsChart/block/EpochTimeDistribution.tsx b/src/pages/StatisticsChart/block/EpochTimeDistribution.tsx index d51c8afcf..9353ba1f1 100644 --- a/src/pages/StatisticsChart/block/EpochTimeDistribution.tsx +++ b/src/pages/StatisticsChart/block/EpochTimeDistribution.tsx @@ -111,8 +111,7 @@ export const EpochTimeDistributionChart = ({ isThumbnail = false }: { isThumbnai fetchData={explorerService.api.fetchStatisticEpochTimeDistribution} getEChartOption={useOption} toCSV={toCSV} - cacheKey="EpochTimeDistribution" - cacheMode="date" + queryKey="fetchStatisticEpochTimeDistribution" /> ) } diff --git a/src/assets/chart_no_data.png b/src/pages/StatisticsChart/common/chart_no_data.png similarity index 100% rename from src/assets/chart_no_data.png rename to src/pages/StatisticsChart/common/chart_no_data.png diff --git a/src/assets/chart_no_data_aggron.png b/src/pages/StatisticsChart/common/chart_no_data_aggron.png similarity index 100% rename from src/assets/chart_no_data_aggron.png rename to src/pages/StatisticsChart/common/chart_no_data_aggron.png diff --git a/src/pages/StatisticsChart/common/index.tsx b/src/pages/StatisticsChart/common/index.tsx index 002b6e05c..e20c2da52 100644 --- a/src/pages/StatisticsChart/common/index.tsx +++ b/src/pages/StatisticsChart/common/index.tsx @@ -13,18 +13,18 @@ import 'echarts/lib/component/brush' import echarts from 'echarts/lib/echarts' import { EChartOption, ECharts } from 'echarts' import { useTranslation } from 'react-i18next' +import { useQuery } from '@tanstack/react-query' import { LoadingPanel, ChartNoDataPanel, ChartDetailTitle, ChartDetailPanel, ChartNotePanel } from './styled' import Loading from '../../../components/Loading' -import ChartNoDataImage from '../../../assets/chart_no_data.png' -import ChartNoDataAggronImage from '../../../assets/chart_no_data_aggron.png' +import ChartNoDataImage from './chart_no_data.png' +import ChartNoDataAggronImage from './chart_no_data_aggron.png' import { isMainnet } from '../../../utils/chain' import SmallLoading from '../../../components/Loading/SmallLoading' import Content from '../../../components/Content' -import { useChartQueryWithCache, useIsMobile, usePrevious, useWindowResize } from '../../../utils/hook' +import { useIsMobile, usePrevious, useWindowResize } from '../../../utils/hook' import { isDeepEqual } from '../../../utils/util' import { HelpTip } from '../../../components/HelpTip' import { ChartColor, ChartColorConfig } from '../../../constants/common' -import { Response } from '../../../services/ExplorerService' const LoadingComp = ({ isThumbnail }: { isThumbnail?: boolean }) => (isThumbnail ? : ) @@ -161,7 +161,7 @@ export interface SmartChartPageProps { note?: string isThumbnail?: boolean chartProps?: Partial> - fetchData: () => Promise[]>> + fetchData: () => Promise onFetched?: (dataList: T[]) => void getEChartOption: ( dataList: T[], @@ -170,8 +170,7 @@ export interface SmartChartPageProps { isThumbnail?: boolean, ) => echarts.EChartOption toCSV: (dataList: T[]) => (string | number)[][] - cacheKey?: string - cacheMode?: 'forever' | 'date' | 'epoch' + queryKey?: string } export function SmartChartPage({ @@ -184,12 +183,11 @@ export function SmartChartPage({ onFetched, getEChartOption, toCSV, - cacheKey, - cacheMode = 'forever', + queryKey, }: SmartChartPageProps): ReactElement { const isMobile = useIsMobile() - const query = useChartQueryWithCache(fetchData, cacheKey, cacheMode) + const query = useQuery(['SmartChartPage', queryKey], () => fetchData(), { refetchOnWindowFocus: false }) const dataList = useMemo(() => query.data ?? [], [query.data]) useEffect(() => { if (onFetched && query.data) { diff --git a/src/pages/StatisticsChart/mining/Difficulty.tsx b/src/pages/StatisticsChart/mining/Difficulty.tsx index da7890285..1c91a506d 100644 --- a/src/pages/StatisticsChart/mining/Difficulty.tsx +++ b/src/pages/StatisticsChart/mining/Difficulty.tsx @@ -108,8 +108,7 @@ export const DifficultyChart = ({ isThumbnail = false }: { isThumbnail?: boolean fetchData={explorerService.api.fetchStatisticDifficulty} getEChartOption={useOption} toCSV={toCSV} - cacheKey="Difficulty" - cacheMode="date" + queryKey="fetchStatisticDifficulty" /> ) } diff --git a/src/pages/StatisticsChart/mining/DifficultyHashRate.tsx b/src/pages/StatisticsChart/mining/DifficultyHashRate.tsx index 40f8532ac..05799bf64 100644 --- a/src/pages/StatisticsChart/mining/DifficultyHashRate.tsx +++ b/src/pages/StatisticsChart/mining/DifficultyHashRate.tsx @@ -201,8 +201,7 @@ export const DifficultyHashRateChart = ({ isThumbnail = false }: { isThumbnail?: fetchData={explorerService.api.fetchStatisticDifficultyHashRate} getEChartOption={useOption} toCSV={toCSV} - cacheKey="DifficultyHashRate" - cacheMode="epoch" + queryKey="fetchStatisticDifficultyHashRate" /> ) } diff --git a/src/pages/StatisticsChart/mining/DifficultyUncleRateEpoch.tsx b/src/pages/StatisticsChart/mining/DifficultyUncleRateEpoch.tsx index 7229f9b0e..a3f6a9373 100644 --- a/src/pages/StatisticsChart/mining/DifficultyUncleRateEpoch.tsx +++ b/src/pages/StatisticsChart/mining/DifficultyUncleRateEpoch.tsx @@ -217,8 +217,7 @@ export const DifficultyUncleRateEpochChart: FC<{ isThumbnail?: boolean }> = ({ i fetchData={explorerService.api.fetchStatisticDifficultyUncleRateEpoch} getEChartOption={useOption} toCSV={toCSV} - cacheKey="DifficultyUncleRateEpoch" - cacheMode="epoch" + queryKey="fetchStatisticDifficultyUncleRateEpoch" /> ) } diff --git a/src/pages/StatisticsChart/mining/HashRate.tsx b/src/pages/StatisticsChart/mining/HashRate.tsx index a0b6d2930..7a580852a 100644 --- a/src/pages/StatisticsChart/mining/HashRate.tsx +++ b/src/pages/StatisticsChart/mining/HashRate.tsx @@ -8,8 +8,6 @@ import { ChartItem, explorerService } from '../../../services/ExplorerService' import { useCurrentLanguage } from '../../../utils/i18n' import { ChartColorConfig } from '../../../constants/common' -export const HashRateCacheKey = 'HashRate' - const useOption = ( statisticHashRates: ChartItem.HashRate[], chartColor: ChartColorConfig, @@ -109,8 +107,7 @@ export const HashRateChart = ({ isThumbnail = false }: { isThumbnail?: boolean } fetchData={explorerService.api.fetchStatisticHashRate} getEChartOption={useOption} toCSV={toCSV} - cacheKey={HashRateCacheKey} - cacheMode="date" + queryKey="fetchStatisticHashRate" /> ) } diff --git a/src/pages/StatisticsChart/mining/MinerAddressDistribution.tsx b/src/pages/StatisticsChart/mining/MinerAddressDistribution.tsx index ce6e70499..d6c30de05 100644 --- a/src/pages/StatisticsChart/mining/MinerAddressDistribution.tsx +++ b/src/pages/StatisticsChart/mining/MinerAddressDistribution.tsx @@ -122,8 +122,7 @@ export const MinerAddressDistributionChart = ({ isThumbnail = false }: { isThumb fetchData={explorerService.api.fetchStatisticMinerAddressDistribution} getEChartOption={getEChartOption} toCSV={toCSV} - cacheKey="MinerAddressDistribution" - cacheMode="date" + queryKey="fetchStatisticMinerAddressDistribution" /> ) } diff --git a/src/pages/StatisticsChart/mining/MinerVersionDistribution.tsx b/src/pages/StatisticsChart/mining/MinerVersionDistribution.tsx index c0e012016..977ab36bf 100644 --- a/src/pages/StatisticsChart/mining/MinerVersionDistribution.tsx +++ b/src/pages/StatisticsChart/mining/MinerVersionDistribution.tsx @@ -121,8 +121,7 @@ export const MinerVersionDistributionChart = ({ isThumbnail = false }: { isThumb fetchData={fetchData} getEChartOption={useOption} toCSV={toCSV} - cacheKey="MinerVersionDistribution" - cacheMode="date" + queryKey="fetchStatisticMinerVersionDistribution" /> ) } diff --git a/src/pages/StatisticsChart/mining/UncleRate.tsx b/src/pages/StatisticsChart/mining/UncleRate.tsx index 8241f77dc..ff3f7abb1 100644 --- a/src/pages/StatisticsChart/mining/UncleRate.tsx +++ b/src/pages/StatisticsChart/mining/UncleRate.tsx @@ -123,8 +123,7 @@ export const UncleRateChart = ({ isThumbnail = false }: { isThumbnail?: boolean fetchData={explorerService.api.fetchStatisticUncleRate} getEChartOption={useOption} toCSV={toCSV} - cacheKey="UncleRate" - cacheMode="date" + queryKey="fetchStatisticUncleRate" /> ) } diff --git a/src/pages/StatisticsChart/monetary/AnnualPercentageCompensation.tsx b/src/pages/StatisticsChart/monetary/AnnualPercentageCompensation.tsx index c74ac19b7..e9b0c30c5 100644 --- a/src/pages/StatisticsChart/monetary/AnnualPercentageCompensation.tsx +++ b/src/pages/StatisticsChart/monetary/AnnualPercentageCompensation.tsx @@ -108,8 +108,7 @@ export const AnnualPercentageCompensationChart = ({ isThumbnail = false }: { isT fetchData={explorerService.api.fetchStatisticAnnualPercentageCompensation} getEChartOption={useOption} toCSV={toCSV} - cacheKey="APC" - cacheMode="forever" + queryKey="fetchStatisticAnnualPercentageCompensation" /> ) } diff --git a/src/pages/StatisticsChart/monetary/InflationRate.tsx b/src/pages/StatisticsChart/monetary/InflationRate.tsx index ca1266fc4..c16c3eea4 100644 --- a/src/pages/StatisticsChart/monetary/InflationRate.tsx +++ b/src/pages/StatisticsChart/monetary/InflationRate.tsx @@ -167,8 +167,7 @@ export const InflationRateChart = ({ isThumbnail = false }: { isThumbnail?: bool fetchData={explorerService.api.fetchStatisticInflationRate} getEChartOption={useOption} toCSV={toCSV} - cacheKey="InflationRate" - cacheMode="forever" + queryKey="fetchStatisticInflationRate" /> ) } diff --git a/src/pages/StatisticsChart/monetary/Liquidity.tsx b/src/pages/StatisticsChart/monetary/Liquidity.tsx index e10e59925..e915cef39 100644 --- a/src/pages/StatisticsChart/monetary/Liquidity.tsx +++ b/src/pages/StatisticsChart/monetary/Liquidity.tsx @@ -197,8 +197,7 @@ export const LiquidityChart = ({ isThumbnail = false }: { isThumbnail?: boolean fetchData={explorerService.api.fetchStatisticLiquidity} getEChartOption={useOption} toCSV={toCSV} - cacheKey="Liquidity" - cacheMode="date" + queryKey="fetchStatisticLiquidity" /> ) } diff --git a/src/pages/StatisticsChart/monetary/SecondaryIssuance.tsx b/src/pages/StatisticsChart/monetary/SecondaryIssuance.tsx index 08b489ca1..fe6206da5 100644 --- a/src/pages/StatisticsChart/monetary/SecondaryIssuance.tsx +++ b/src/pages/StatisticsChart/monetary/SecondaryIssuance.tsx @@ -191,8 +191,7 @@ export const SecondaryIssuanceChart = ({ isThumbnail = false }: { isThumbnail?: fetchData={explorerService.api.fetchStatisticSecondaryIssuance} getEChartOption={useOption} toCSV={toCSV} - cacheKey="SecondaryIssuance" - cacheMode="date" + queryKey="fetchStatisticSecondaryIssuance" /> ) } diff --git a/src/pages/StatisticsChart/monetary/TotalSupply.tsx b/src/pages/StatisticsChart/monetary/TotalSupply.tsx index 344600b62..ddb0773a1 100644 --- a/src/pages/StatisticsChart/monetary/TotalSupply.tsx +++ b/src/pages/StatisticsChart/monetary/TotalSupply.tsx @@ -207,8 +207,7 @@ export const TotalSupplyChart = ({ isThumbnail = false }: { isThumbnail?: boolea fetchData={explorerService.api.fetchStatisticTotalSupply} getEChartOption={useOption} toCSV={toCSV} - cacheKey="TotalSupply" - cacheMode="date" + queryKey="fetchStatisticTotalSupply" /> ) } diff --git a/src/pages/StatisticsChart/nervosDao/CirculationRatio.tsx b/src/pages/StatisticsChart/nervosDao/CirculationRatio.tsx index 50920129f..0979a33c8 100644 --- a/src/pages/StatisticsChart/nervosDao/CirculationRatio.tsx +++ b/src/pages/StatisticsChart/nervosDao/CirculationRatio.tsx @@ -109,8 +109,7 @@ export const CirculationRatioChart = ({ isThumbnail = false }: { isThumbnail?: b fetchData={explorerService.api.fetchStatisticCirculationRatio} getEChartOption={useOption} toCSV={toCSV} - cacheKey="DepositCirculationRatio" - cacheMode="date" + queryKey="fetchStatisticCirculationRatio" /> ) } diff --git a/src/pages/StatisticsChart/nervosDao/NewDaoDeposit.tsx b/src/pages/StatisticsChart/nervosDao/NewDaoDeposit.tsx index 8d908acae..1c470fee3 100644 --- a/src/pages/StatisticsChart/nervosDao/NewDaoDeposit.tsx +++ b/src/pages/StatisticsChart/nervosDao/NewDaoDeposit.tsx @@ -196,8 +196,7 @@ export const NewDaoDepositChart = ({ isThumbnail = false }: { isThumbnail?: bool fetchData={explorerService.api.fetchStatisticNewDaoDeposit} getEChartOption={useOption} toCSV={toCSV} - cacheKey="DailyDeposit" - cacheMode="date" + queryKey="fetchStatisticNewDaoDeposit" /> ) } diff --git a/src/pages/StatisticsChart/nervosDao/TotalDaoDeposit.tsx b/src/pages/StatisticsChart/nervosDao/TotalDaoDeposit.tsx index 641c92a17..a68ed9478 100644 --- a/src/pages/StatisticsChart/nervosDao/TotalDaoDeposit.tsx +++ b/src/pages/StatisticsChart/nervosDao/TotalDaoDeposit.tsx @@ -195,8 +195,7 @@ export const TotalDaoDepositChart = ({ isThumbnail = false }: { isThumbnail?: bo fetchData={explorerService.api.fetchStatisticTotalDaoDeposit} getEChartOption={useOption} toCSV={toCSV} - cacheKey="TotalDeposit" - cacheMode="date" + queryKey="fetchStatisticTotalDaoDeposit" /> ) } diff --git a/src/assets/clock.svg b/src/pages/Transaction/TransactionCell/clock.svg similarity index 100% rename from src/assets/clock.svg rename to src/pages/Transaction/TransactionCell/clock.svg diff --git a/src/assets/cota_cell.svg b/src/pages/Transaction/TransactionCell/cota_cell.svg similarity index 100% rename from src/assets/cota_cell.svg rename to src/pages/Transaction/TransactionCell/cota_cell.svg diff --git a/src/assets/cota_reg_cell.svg b/src/pages/Transaction/TransactionCell/cota_reg_cell.svg similarity index 100% rename from src/assets/cota_reg_cell.svg rename to src/pages/Transaction/TransactionCell/cota_reg_cell.svg diff --git a/src/pages/Transaction/TransactionCell/index.tsx b/src/pages/Transaction/TransactionCell/index.tsx index 735516ebc..4df3ae328 100644 --- a/src/pages/Transaction/TransactionCell/index.tsx +++ b/src/pages/Transaction/TransactionCell/index.tsx @@ -24,13 +24,13 @@ import DecimalCapacity from '../../../components/DecimalCapacity' import NervosDAODepositIcon from '../../../assets/nervos_dao_cell.png' import NervosDAOWithdrawingIcon from '../../../assets/nervos_dao_withdrawing.png' import UDTTokenIcon from '../../../assets/udt_token.png' -import NFTIssuerIcon from '../../../assets/m_nft_issuer.svg' -import NFTClassIcon from '../../../assets/m_nft_class.svg' -import NFTTokenIcon from '../../../assets/m_nft.svg' -import CoTACellIcon from '../../../assets/cota_cell.svg' -import CoTARegCellIcon from '../../../assets/cota_reg_cell.svg' -import SporeCellIcon from '../../../assets/spore.svg' -import { ReactComponent as LockTimeIcon } from '../../../assets/clock.svg' +import NFTIssuerIcon from './m_nft_issuer.svg' +import NFTClassIcon from './m_nft_class.svg' +import NFTTokenIcon from './m_nft.svg' +import CoTACellIcon from './cota_cell.svg' +import CoTARegCellIcon from './cota_reg_cell.svg' +import SporeCellIcon from './spore.svg' +import { ReactComponent as LockTimeIcon } from './clock.svg' import { ReactComponent as BitAccountIcon } from '../../../assets/bit_account.svg' import TransactionCellScript from '../TransactionCellScript' import SimpleModal from '../../../components/Modal' diff --git a/src/assets/m_nft.svg b/src/pages/Transaction/TransactionCell/m_nft.svg similarity index 100% rename from src/assets/m_nft.svg rename to src/pages/Transaction/TransactionCell/m_nft.svg diff --git a/src/assets/m_nft_class.svg b/src/pages/Transaction/TransactionCell/m_nft_class.svg similarity index 100% rename from src/assets/m_nft_class.svg rename to src/pages/Transaction/TransactionCell/m_nft_class.svg diff --git a/src/assets/m_nft_issuer.svg b/src/pages/Transaction/TransactionCell/m_nft_issuer.svg similarity index 100% rename from src/assets/m_nft_issuer.svg rename to src/pages/Transaction/TransactionCell/m_nft_issuer.svg diff --git a/src/assets/spore.svg b/src/pages/Transaction/TransactionCell/spore.svg similarity index 100% rename from src/assets/spore.svg rename to src/pages/Transaction/TransactionCell/spore.svg diff --git a/src/assets/deprecated_addr_off.svg b/src/pages/Transaction/TransactionCellList/deprecated_addr_off.svg similarity index 100% rename from src/assets/deprecated_addr_off.svg rename to src/pages/Transaction/TransactionCellList/deprecated_addr_off.svg diff --git a/src/assets/deprecated_addr_on.svg b/src/pages/Transaction/TransactionCellList/deprecated_addr_on.svg similarity index 100% rename from src/assets/deprecated_addr_on.svg rename to src/pages/Transaction/TransactionCellList/deprecated_addr_on.svg diff --git a/src/pages/Transaction/TransactionCellList/index.tsx b/src/pages/Transaction/TransactionCellList/index.tsx index 0a49a8243..71f9b174f 100644 --- a/src/pages/Transaction/TransactionCellList/index.tsx +++ b/src/pages/Transaction/TransactionCellList/index.tsx @@ -5,9 +5,9 @@ import { CellType, PAGE_CELL_COUNT } from '../../../constants/common' import TransactionCell from '../TransactionCell' import { TransactionCellListPanel, TransactionCellListTitlePanel, TransactionCellsPanel } from './styled' import SmallLoading from '../../../components/Loading/SmallLoading' -import { ReactComponent as DeprecatedAddrOn } from '../../../assets/deprecated_addr_on.svg' -import { ReactComponent as DeprecatedAddrOff } from '../../../assets/deprecated_addr_off.svg' -import { ReactComponent as Warning } from '../../../assets/warning.svg' +import { ReactComponent as DeprecatedAddrOn } from './deprecated_addr_on.svg' +import { ReactComponent as DeprecatedAddrOff } from './deprecated_addr_off.svg' +import { ReactComponent as Warning } from './warning.svg' import styles from './styles.module.scss' import { Cell } from '../../../models/Cell' import { useIsDeprecatedAddressesDisplayed } from '../../../services/AppSettings/hooks' diff --git a/src/assets/warning.svg b/src/pages/Transaction/TransactionCellList/warning.svg similarity index 100% rename from src/assets/warning.svg rename to src/pages/Transaction/TransactionCellList/warning.svg diff --git a/src/pages/Transaction/TransactionCellScript/index.tsx b/src/pages/Transaction/TransactionCellScript/index.tsx index 6d09df3f9..0f37d4ba5 100644 --- a/src/pages/Transaction/TransactionCellScript/index.tsx +++ b/src/pages/Transaction/TransactionCellScript/index.tsx @@ -18,12 +18,12 @@ import { TransactionDetailScriptButton, } from './styled' import SmallLoading from '../../../components/Loading/SmallLoading' -import CloseIcon from '../../../assets/modal_close.png' +import CloseIcon from './modal_close.png' import { getContractHashTag } from '../../../utils/util' import { localeNumberString } from '../../../utils/number' import HashTag from '../../../components/HashTag' import { ReactComponent as CopyIcon } from '../../../assets/copy_icon.svg' -import { ReactComponent as OuterLinkIcon } from '../../../assets/outer_link_icon.svg' +import { ReactComponent as OuterLinkIcon } from './outer_link_icon.svg' import { HelpTip } from '../../../components/HelpTip' import { useSetToast } from '../../../components/Toast' import { CellBasicInfo } from '../../../utils/transformer' diff --git a/src/assets/modal_close.png b/src/pages/Transaction/TransactionCellScript/modal_close.png similarity index 100% rename from src/assets/modal_close.png rename to src/pages/Transaction/TransactionCellScript/modal_close.png diff --git a/src/assets/outer_link_icon.svg b/src/pages/Transaction/TransactionCellScript/outer_link_icon.svg similarity index 100% rename from src/assets/outer_link_icon.svg rename to src/pages/Transaction/TransactionCellScript/outer_link_icon.svg diff --git a/src/pages/Transaction/TransactionComp/TransactionOverview.tsx b/src/pages/Transaction/TransactionComp/TransactionOverview.tsx index 33763d582..99ea8c321 100644 --- a/src/pages/Transaction/TransactionComp/TransactionOverview.tsx +++ b/src/pages/Transaction/TransactionComp/TransactionOverview.tsx @@ -24,6 +24,9 @@ import { TransactionInfoContentPanel, TransactionOverviewPanel, TransactionInfoItemPanel, + TransactionInfoContentContainer, + TransactionInfoContentTitle, + TransactionInfoContentTag, } from './styled' import { useLatestBlockNumber } from '../../../services/ExplorerService' import { Transaction } from '../../../models/Transaction' @@ -62,7 +65,7 @@ const TransactionInfoItem = ({ tag?: ReactNode }) => ( -
+ {title ? ( <> {title} @@ -72,9 +75,9 @@ const TransactionInfoItem = ({ ) : ( '' )} -
-
-
+ + +
{linkUrl ? ( {value} @@ -84,8 +87,8 @@ const TransactionInfoItem = ({ )} {valueTooltip && }
- {tag &&
{tag}
} -
+ {tag && {tag}} + ) diff --git a/src/pages/Transaction/TransactionComp/styled.tsx b/src/pages/Transaction/TransactionComp/styled.tsx index 375958425..1253dd95c 100644 --- a/src/pages/Transaction/TransactionComp/styled.tsx +++ b/src/pages/Transaction/TransactionComp/styled.tsx @@ -104,7 +104,6 @@ export const TransactionInfoItemPanel = styled.div` } .transactionInfoValue { - margin-left: 10px; margin-top: 5px; max-height: 250px; font-size: 16px; @@ -121,6 +120,28 @@ export const TransactionInfoContentPanel = styled.div` margin: 15px 0; ` +export const TransactionInfoContentTitle = styled.div` + flex: 0 0 auto; + width: 160px; +` + +export const TransactionInfoContentContainer = styled.div` + display: flex; + + @media (max-width: 1150px) { + display: block; + } +` + +export const TransactionInfoContentTag = styled.div` + margin-left: 10px; + margin-top: 3px; + + @media (max-width: 1150px) { + margin-left: 0; + } +` + export const TransactionInfoContentItem = styled.div` display: flex; margin: 5px 0; diff --git a/src/utils/hook.ts b/src/utils/hook.ts index 7f19c7b89..d03ea95ab 100644 --- a/src/utils/hook.ts +++ b/src/utils/hook.ts @@ -8,24 +8,15 @@ import { systemScripts, } from '@nervosnetwork/ckb-sdk-utils' import { useHistory, useLocation } from 'react-router-dom' -import { useQuery } from '@tanstack/react-query' import { useResizeDetector } from 'react-resize-detector' import { interval, share } from 'rxjs' -import dayjs from 'dayjs' import { deprecatedAddrToNewAddr } from './util' import { startEndEllipsis } from './string' -import { - ListPageParams, - PageParams, - THEORETICAL_EPOCH_TIME, - EPOCHS_PER_HALVING, - ONE_YEAR_MILLISECOND, - ONE_HOUR_MILLISECOND, -} from '../constants/common' +import { ListPageParams, PageParams, THEORETICAL_EPOCH_TIME, EPOCHS_PER_HALVING } from '../constants/common' import { omit } from './object' // TODO: This file depends on higher-level abstractions, so it should not be in the utils folder. It should be moved to `src/hooks/index.ts`. import { useParseDate } from './date' -import { Response, useStatistics } from '../services/ExplorerService' +import { useStatistics } from '../services/ExplorerService' import { cacheService } from '../services/CacheService' /** @@ -509,46 +500,6 @@ export const useDeprecatedAddr = (addr: string) => } }, [addr]) -export function useChartQueryWithCache( - fetchData: () => Promise[]>>, - cacheKey?: string, - cacheMode: 'forever' | 'date' | 'epoch' = 'forever', -) { - return useQuery([fetchData, cacheKey, cacheMode], async () => { - if (cacheKey) { - const dataList = cacheService.get(cacheKey) - if (dataList) return dataList - } - - let dataList = await fetchData() - if ('data' in dataList) { - dataList = dataList.data.map(wrapper => wrapper.attributes) - } - if (cacheKey && dataList.length > 0) { - let expireAt: Date | number - switch (cacheMode) { - case 'epoch': - expireAt = Date.now() + ONE_HOUR_MILLISECOND * 3 - break - case 'date': { - // Chart data will be updated at 08:10(CST) every day - const now = dayjs().utc() - const todayUpdateTime = now.hour(8).minute(11).second(0).millisecond(0) - const nextUpdateTime = now.isBefore(todayUpdateTime) ? todayUpdateTime : todayUpdateTime.add(1, 'day') - expireAt = nextUpdateTime.toDate() - break - } - case 'forever': - default: - expireAt = Date.now() + ONE_YEAR_MILLISECOND * 100 - break - } - cacheService.set(cacheKey, dataList, { expireAt }) - } - return dataList - }) -} - export const useAnimationFrame = (callback: () => void, running: boolean = true) => { const savedCallback = useRef(callback) diff --git a/src/utils/number.ts b/src/utils/number.ts index e96fc7e46..987ebc6ea 100644 --- a/src/utils/number.ts +++ b/src/utils/number.ts @@ -79,7 +79,7 @@ export const parseUDTAmount = (amount: string, decimal: string | number) => { if (decimalInt > 20) { return `${result.toFixed(20)}...` } - if (result.toString().length >= 16 || result.lt(new BigNumber(0.000001))) { + if (result.toString().length >= 16 || result.abs().lt(new BigNumber(0.000001))) { return localeNumberString(result.toFixed(decimalInt)) } return localeNumberString(result.toNumber()) diff --git a/yarn.lock b/yarn.lock index 695c394fa..79e1dd6f2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2656,10 +2656,10 @@ resolved "https://registry.yarnpkg.com/@types/deep-freeze-strict/-/deep-freeze-strict-1.1.0.tgz#447a6a2576191344aa42310131dd3df5c41492c4" integrity sha512-fILflsS66kGQ4iIBzYoxuQCWK1wQdy/ooguTofUk0KSxA+G5ZzH8WdU8mf6IU+5cMBW+j9u+eh+7kv63R3O9Tw== -"@types/echarts@4.9.19": - version "4.9.19" - resolved "https://registry.yarnpkg.com/@types/echarts/-/echarts-4.9.19.tgz#6c50ccde9f4458edfc36a9c78f81511ec1853941" - integrity sha512-mtQzTmBFLQ1tyAmP667OTr7oOceyfqHRMa0tkIj9FBOKYY0ggG6OGE4AfUtDw2gOuPEEw4vzD+y0OJWKi1IZHQ== +"@types/echarts@4.9.21": + version "4.9.21" + resolved "https://registry.yarnpkg.com/@types/echarts/-/echarts-4.9.21.tgz#9626d0db7215cf51cbfe02a42c05d9d2834f243a" + integrity sha512-xUvHN2TbednNO3bybnG8GtOWU/f+/ouSlC9wO+704uiRlVtPEcLPfvfD24WqZ8uAXJ2dvlBLeB60WIlzv+Xajw== dependencies: "@types/zrender" "*" @@ -2842,10 +2842,10 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-13.11.0.tgz#390ea202539c61c8fa6ba4428b57e05bc36dc47b" integrity sha512-uM4mnmsIIPK/yeO+42F2RQhGUIs39K2RFmugcJANppXe6J1nvH87PvzPZYpza7Xhhs8Yn9yIAVdLZ84z61+0xQ== -"@types/node@16.18.58": - version "16.18.58" - resolved "https://registry.yarnpkg.com/@types/node/-/node-16.18.58.tgz#bf66f63983104ed57c754f4e84ccaf16f8235adb" - integrity sha512-YGncyA25/MaVtQkjWW9r0EFBukZ+JulsLcVZBlGUfIb96OBMjkoRWwQo5IEWJ8Fj06Go3GHw+bjYDitv6BaGsA== +"@types/node@16.18.61": + version "16.18.61" + resolved "https://registry.yarnpkg.com/@types/node/-/node-16.18.61.tgz#5ea47e3018348bf3bbbe646b396ba5e720310be1" + integrity sha512-k0N7BqGhJoJzdh6MuQg1V1ragJiXTh8VUBAZTWjJ9cUq23SG0F0xavOwZbhiP4J3y20xd6jxKx+xNUhkMAi76Q== "@types/normalize-package-data@^2.4.0": version "2.4.1"