diff --git a/.changeset/forty-suns-sneeze.md b/.changeset/forty-suns-sneeze.md new file mode 100644 index 000000000..e7d26c3b0 --- /dev/null +++ b/.changeset/forty-suns-sneeze.md @@ -0,0 +1,6 @@ +--- +'@siafoundation/design-system': minor +'@siafoundation/units': minor +--- + +Time conversion helpers were moved from design-system to units package. diff --git a/.changeset/funny-ravens-sneeze.md b/.changeset/funny-ravens-sneeze.md new file mode 100644 index 000000000..b8523babc --- /dev/null +++ b/.changeset/funny-ravens-sneeze.md @@ -0,0 +1,5 @@ +--- +'@siafoundation/design-system': minor +--- + +Fiat components requiring exchange rate now use the generic useExchangeRate hook rather than useSiascanExchangeRate directly. diff --git a/.changeset/short-cows-attend.md b/.changeset/short-cows-attend.md new file mode 100644 index 000000000..a42e6d529 --- /dev/null +++ b/.changeset/short-cows-attend.md @@ -0,0 +1,6 @@ +--- +'@siafoundation/design-system': minor +'@siafoundation/react-core': minor +--- + +Exchange rate hooks were moved from design-system to react-core. diff --git a/apps/hostd/components/Config/AnnounceButton.tsx b/apps/hostd/components/Config/AnnounceButton.tsx index 1b7db4420..727129639 100644 --- a/apps/hostd/components/Config/AnnounceButton.tsx +++ b/apps/hostd/components/Config/AnnounceButton.tsx @@ -1,7 +1,6 @@ import { Button, Paragraph, - minutesInMilliseconds, triggerErrorToast, triggerSuccessToast, } from '@siafoundation/design-system' @@ -13,7 +12,7 @@ import { useHostState, useTxPoolFee, } from '@siafoundation/hostd-react' -import { humanSiacoin } from '@siafoundation/units' +import { humanSiacoin, minutesInMilliseconds } from '@siafoundation/units' import { useCallback } from 'react' import BigNumber from 'bignumber.js' diff --git a/apps/hostd/config/swr.ts b/apps/hostd/config/swr.ts index 23d7e1297..6e3827779 100644 --- a/apps/hostd/config/swr.ts +++ b/apps/hostd/config/swr.ts @@ -1,3 +1,3 @@ -import { secondsInMilliseconds } from '@siafoundation/design-system' +import { secondsInMilliseconds } from '@siafoundation/units' export const defaultDatasetRefreshInterval = secondsInMilliseconds(15) diff --git a/apps/hostd/contexts/config/useForm.tsx b/apps/hostd/contexts/config/useForm.tsx index fd87f0f25..2960d5392 100644 --- a/apps/hostd/contexts/config/useForm.tsx +++ b/apps/hostd/contexts/config/useForm.tsx @@ -5,7 +5,7 @@ import { getFields } from './fields' import useLocalStorageState from 'use-local-storage-state' import { useHostState } from '@siafoundation/hostd-react' import { useAutoCalculatedFields } from './useAutoCalculatedFields' -import { useExchangeRate } from '@siafoundation/design-system' +import { useExchangeRate } from '@siafoundation/react-core' export function useForm() { const form = useHookForm({ diff --git a/apps/hostd/contexts/config/useOnValid.tsx b/apps/hostd/contexts/config/useOnValid.tsx index e7fbf9360..3c6373bdb 100644 --- a/apps/hostd/contexts/config/useOnValid.tsx +++ b/apps/hostd/contexts/config/useOnValid.tsx @@ -1,7 +1,6 @@ import { triggerSuccessToast, triggerErrorToast, - minutesInMilliseconds, } from '@siafoundation/design-system' import { useCallback } from 'react' import { SettingsData } from './types' @@ -12,6 +11,7 @@ import { useSettingsPinnedUpdate, useSettingsUpdate, } from '@siafoundation/hostd-react' +import { minutesInMilliseconds } from '@siafoundation/units' export function useOnValid({ resources, diff --git a/apps/hostd/contexts/config/useResources.tsx b/apps/hostd/contexts/config/useResources.tsx index b4d7d1861..f465ba7e0 100644 --- a/apps/hostd/contexts/config/useResources.tsx +++ b/apps/hostd/contexts/config/useResources.tsx @@ -1,9 +1,9 @@ -import { minutesInMilliseconds } from '@siafoundation/design-system' import { useSettings, useSettingsDdnsUpdate, useSettingsPinned, } from '@siafoundation/hostd-react' +import { minutesInMilliseconds } from '@siafoundation/units' export function useResources() { const settings = useSettings({ diff --git a/apps/hostd/contexts/metrics/index.tsx b/apps/hostd/contexts/metrics/index.tsx index b005e83bc..0916b291a 100644 --- a/apps/hostd/contexts/metrics/index.tsx +++ b/apps/hostd/contexts/metrics/index.tsx @@ -5,7 +5,6 @@ import { formatChartData, getDataIntervalLabelFormatter, getTimeRange, - secondsInMilliseconds, ValueScFiat, } from '@siafoundation/design-system' import { @@ -13,6 +12,7 @@ import { humanBytes, humanNumber, humanSiacoin, + secondsInMilliseconds, } from '@siafoundation/units' import { useCallback, useMemo } from 'react' import { chartConfigs } from '../../config/charts' diff --git a/apps/hostd/contexts/metrics/types.tsx b/apps/hostd/contexts/metrics/types.tsx index e47b143f6..56a2f0c84 100644 --- a/apps/hostd/contexts/metrics/types.tsx +++ b/apps/hostd/contexts/metrics/types.tsx @@ -2,7 +2,7 @@ import { daysInMilliseconds, hoursInMilliseconds, minutesInMilliseconds, -} from '@siafoundation/design-system' +} from '@siafoundation/units' export type RevenueKeys = | 'rpcPotential' diff --git a/apps/hostd/contexts/metrics/useNowAtInterval.tsx b/apps/hostd/contexts/metrics/useNowAtInterval.tsx index c84a21756..01acffc28 100644 --- a/apps/hostd/contexts/metrics/useNowAtInterval.tsx +++ b/apps/hostd/contexts/metrics/useNowAtInterval.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from 'react' import { DataInterval, getDataIntervalInMs } from './types' -import { hoursInMilliseconds } from '@siafoundation/design-system' +import { hoursInMilliseconds } from '@siafoundation/units' // now timestamp updated every interval // used to reset the time range and keep the graph up to date diff --git a/apps/hostd/contexts/transactions/index.tsx b/apps/hostd/contexts/transactions/index.tsx index 00a3dfb43..be19acc83 100644 --- a/apps/hostd/contexts/transactions/index.tsx +++ b/apps/hostd/contexts/transactions/index.tsx @@ -1,5 +1,4 @@ import { - daysInMilliseconds, useDatasetEmptyState, useServerFilters, useTableState, @@ -20,6 +19,7 @@ import { getEventContractId, getEventFee, getEventTxType, + daysInMilliseconds, } from '@siafoundation/units' import { CellContext, diff --git a/apps/hostd/contexts/volumes/index.tsx b/apps/hostd/contexts/volumes/index.tsx index 185c7140b..ce21b86e0 100644 --- a/apps/hostd/contexts/volumes/index.tsx +++ b/apps/hostd/contexts/volumes/index.tsx @@ -1,7 +1,6 @@ import { useTableState, useDatasetEmptyState, - secondsInMilliseconds, } from '@siafoundation/design-system' import { VolumeMeta } from '@siafoundation/hostd-types' import { useVolumes as useVolumesData } from '@siafoundation/hostd-react' @@ -10,6 +9,7 @@ import { columnsDefaultVisible, TableColumnId } from './types' import { columns } from './columns' import { useDataset } from './dataset' import { defaultDatasetRefreshInterval } from '../../config/swr' +import { secondsInMilliseconds } from '@siafoundation/units' function useVolumesMain() { const { diff --git a/apps/hostd/hooks/useSyncStatus.ts b/apps/hostd/hooks/useSyncStatus.ts index e576cf0f9..cf8950492 100644 --- a/apps/hostd/hooks/useSyncStatus.ts +++ b/apps/hostd/hooks/useSyncStatus.ts @@ -4,7 +4,7 @@ import { useConsensusTipState, useIndexTip, } from '@siafoundation/hostd-react' -import { hoursInMilliseconds } from '@siafoundation/design-system' +import { hoursInMilliseconds } from '@siafoundation/units' export function useSyncStatus() { const { isUnlockedAndAuthedRoute } = useAppSettings() diff --git a/apps/renterd/components/Contracts/ContractsCmd/ContractsFilterCmd/ContractFilterCmdGroups/Expiry.tsx b/apps/renterd/components/Contracts/ContractsCmd/ContractsFilterCmd/ContractFilterCmdGroups/Expiry.tsx index 93fea7182..9155ceedc 100644 --- a/apps/renterd/components/Contracts/ContractsCmd/ContractsFilterCmd/ContractFilterCmdGroups/Expiry.tsx +++ b/apps/renterd/components/Contracts/ContractsCmd/ContractsFilterCmd/ContractFilterCmdGroups/Expiry.tsx @@ -3,8 +3,8 @@ import { weeksInMilliseconds, monthsInMilliseconds, yearsInMilliseconds, - ClientFilterItem, -} from '@siafoundation/design-system' +} from '@siafoundation/units' +import { ClientFilterItem } from '@siafoundation/design-system' import { ContractData } from '../../../../../contexts/contracts/types' import { CommandGroup, CommandItemSearch } from '../../../../CmdRoot/Item' import { Page } from '../../../../CmdRoot/types' diff --git a/apps/renterd/components/Contracts/ContractsCmd/ContractsFilterCmd/ContractFilterCmdGroups/Formation.tsx b/apps/renterd/components/Contracts/ContractsCmd/ContractsFilterCmd/ContractFilterCmdGroups/Formation.tsx index 3a158ac55..7fd4735b6 100644 --- a/apps/renterd/components/Contracts/ContractsCmd/ContractsFilterCmd/ContractFilterCmdGroups/Formation.tsx +++ b/apps/renterd/components/Contracts/ContractsCmd/ContractsFilterCmd/ContractFilterCmdGroups/Formation.tsx @@ -3,8 +3,8 @@ import { weeksInMilliseconds, monthsInMilliseconds, yearsInMilliseconds, - ClientFilterItem, -} from '@siafoundation/design-system' +} from '@siafoundation/units' +import { ClientFilterItem } from '@siafoundation/design-system' import { ContractData } from '../../../../../contexts/contracts/types' import { CommandGroup, CommandItemSearch } from '../../../../CmdRoot/Item' import { Page } from '../../../../CmdRoot/types' diff --git a/apps/renterd/components/Contracts/ContractsCmd/ContractsFilterCmd/ContractFilterCmdGroups/Renew.tsx b/apps/renterd/components/Contracts/ContractsCmd/ContractsFilterCmd/ContractFilterCmdGroups/Renew.tsx index 405ae7ef8..c8a7cf2a1 100644 --- a/apps/renterd/components/Contracts/ContractsCmd/ContractsFilterCmd/ContractFilterCmdGroups/Renew.tsx +++ b/apps/renterd/components/Contracts/ContractsCmd/ContractsFilterCmd/ContractFilterCmdGroups/Renew.tsx @@ -3,8 +3,8 @@ import { weeksInMilliseconds, monthsInMilliseconds, yearsInMilliseconds, - ClientFilterItem, -} from '@siafoundation/design-system' +} from '@siafoundation/units' +import { ClientFilterItem } from '@siafoundation/design-system' import { ContractData } from '../../../../../contexts/contracts/types' import { CommandGroup, CommandItemSearch } from '../../../../CmdRoot/Item' import { Page } from '../../../../CmdRoot/types' diff --git a/apps/renterd/components/Files/FilesStatsMenuShared/FilesStatsMenuSize.tsx b/apps/renterd/components/Files/FilesStatsMenuShared/FilesStatsMenuSize.tsx index 7f0f32723..c080bbac6 100644 --- a/apps/renterd/components/Files/FilesStatsMenuShared/FilesStatsMenuSize.tsx +++ b/apps/renterd/components/Files/FilesStatsMenuShared/FilesStatsMenuSize.tsx @@ -3,10 +3,9 @@ import { Separator, Text, Tooltip, - minutesInMilliseconds, } from '@siafoundation/design-system' import { useObjectStats } from '@siafoundation/renterd-react' -import { humanBytes } from '@siafoundation/units' +import { humanBytes, minutesInMilliseconds } from '@siafoundation/units' export function FilesStatsMenuSize() { const stats = useObjectStats({ diff --git a/apps/renterd/components/Hosts/HostContextMenu.tsx b/apps/renterd/components/Hosts/HostContextMenu.tsx index 0be4db5b3..cf4e4aa84 100644 --- a/apps/renterd/components/Hosts/HostContextMenu.tsx +++ b/apps/renterd/components/Hosts/HostContextMenu.tsx @@ -5,7 +5,6 @@ import { DropdownMenuLeftSlot, DropdownMenuLabel, Text, - secondsInMilliseconds, truncate, copyToClipboard, } from '@siafoundation/design-system' @@ -32,6 +31,7 @@ import { useBlocklistUpdate } from '../../hooks/useBlocklistUpdate' import { addressContainsFilter } from '../Contracts/ContractsFilterAddressDialog' import { publicKeyContainsFilter } from '../Contracts/ContractsFilterPublicKeyDialog' import { filterPublicKeyEquals } from './HostsFilterPublicKeyDialog' +import { secondsInMilliseconds } from '@siafoundation/units' type Props = { address: string diff --git a/apps/renterd/components/Hosts/HostMap/Globe.tsx b/apps/renterd/components/Hosts/HostMap/Globe.tsx index e268cfe15..67e36bff2 100644 --- a/apps/renterd/components/Hosts/HostMap/Globe.tsx +++ b/apps/renterd/components/Hosts/HostMap/Globe.tsx @@ -2,14 +2,13 @@ import { useEffect, useRef, useCallback, useMemo } from 'react' import { GlobeMethods } from 'react-globe.gl' import { getHostLabel } from './utils' import { useElementSize } from 'usehooks-ts' -import { useTryUntil } from '@siafoundation/react-core' +import { useTryUntil, useExchangeRate } from '@siafoundation/react-core' import earthDarkContrast from '../../../assets/earth-dark-contrast.png' import earthTopology from '../../../assets/earth-topology.png' import { GlobeDyn } from './GlobeDyn' import { HostDataWithLocation } from '../../../contexts/hosts/types' import BigNumber from 'bignumber.js' import { getHostStatus } from '../../../contexts/hosts/status' -import { useExchangeRate } from '@siafoundation/design-system' export type Commands = { moveToLocation: ( diff --git a/apps/renterd/config/swr.ts b/apps/renterd/config/swr.ts index 23d7e1297..6e3827779 100644 --- a/apps/renterd/config/swr.ts +++ b/apps/renterd/config/swr.ts @@ -1,3 +1,3 @@ -import { secondsInMilliseconds } from '@siafoundation/design-system' +import { secondsInMilliseconds } from '@siafoundation/units' export const defaultDatasetRefreshInterval = secondsInMilliseconds(15) diff --git a/apps/renterd/contexts/app/useAutopilot.tsx b/apps/renterd/contexts/app/useAutopilot.tsx index 2e830f2cb..d2cb73ab4 100644 --- a/apps/renterd/contexts/app/useAutopilot.tsx +++ b/apps/renterd/contexts/app/useAutopilot.tsx @@ -1,4 +1,4 @@ -import { secondsInMilliseconds } from '@siafoundation/design-system' +import { secondsInMilliseconds } from '@siafoundation/units' import { useAutopilotState } from '@siafoundation/renterd-react' import { useEffect, useState } from 'react' diff --git a/apps/renterd/contexts/config/fields.tsx b/apps/renterd/contexts/config/fields.tsx index ba95f02c6..fc8a59711 100644 --- a/apps/renterd/contexts/config/fields.tsx +++ b/apps/renterd/contexts/config/fields.tsx @@ -4,10 +4,9 @@ import { ConfigFields, Link, Text, - hoursInDays, - secondsInMinutes, toFixedMaxString, } from '@siafoundation/design-system' +import { hoursInDays, secondsInMinutes } from '@siafoundation/units' import BigNumber from 'bignumber.js' import React from 'react' import { diff --git a/apps/renterd/contexts/config/transformDown.ts b/apps/renterd/contexts/config/transformDown.ts index 0b2f9ce41..6752b2a13 100644 --- a/apps/renterd/contexts/config/transformDown.ts +++ b/apps/renterd/contexts/config/transformDown.ts @@ -1,6 +1,4 @@ import { - nanosecondsInDays, - nanosecondsInMinutes, toFixedMaxBigNumber, toFixedMaxString, } from '@siafoundation/design-system' @@ -20,6 +18,8 @@ import { valuePerPeriodToPerMonth, valuePerOneToPerMillion, weeksToBlocks, + nanosecondsInDays, + nanosecondsInMinutes, } from '@siafoundation/units' import BigNumber from 'bignumber.js' import { diff --git a/apps/renterd/contexts/config/transformUp.ts b/apps/renterd/contexts/config/transformUp.ts index 3625bf0ba..3ba8aa5ff 100644 --- a/apps/renterd/contexts/config/transformUp.ts +++ b/apps/renterd/contexts/config/transformUp.ts @@ -1,7 +1,3 @@ -import { - daysInNanoseconds, - minutesInNanoseconds, -} from '@siafoundation/design-system' import { AutopilotConfig, ContractSetSettings, @@ -17,6 +13,8 @@ import { valuePerTBPerMonthToPerBytePerBlock, valuePerMonthToPerPeriod, valuePerMillionToPerOne, + daysInNanoseconds, + minutesInNanoseconds, } from '@siafoundation/units' import { AutopilotData, diff --git a/apps/renterd/contexts/config/useAllowanceDerivedPricing.tsx b/apps/renterd/contexts/config/useAllowanceDerivedPricing.tsx index 8c6de79e8..166ccf631 100644 --- a/apps/renterd/contexts/config/useAllowanceDerivedPricing.tsx +++ b/apps/renterd/contexts/config/useAllowanceDerivedPricing.tsx @@ -4,7 +4,6 @@ import { UseFormReturn } from 'react-hook-form' import BigNumber from 'bignumber.js' import useSWR from 'swr' import axios from 'axios' -import { minutesInMilliseconds } from '@siafoundation/design-system' import { calculateIdealAllowance, derivePricingFromAllowance, @@ -17,7 +16,11 @@ import { storageWeight, uploadWeight, } from './deriveAllowanceConfig' -import { fiatToSiacoin, siacoinToFiat } from '@siafoundation/units' +import { + fiatToSiacoin, + siacoinToFiat, + minutesInMilliseconds, +} from '@siafoundation/units' export function useForexExchangeRate({ form, diff --git a/apps/renterd/contexts/config/useResources.tsx b/apps/renterd/contexts/config/useResources.tsx index 5b6753383..f36240dd5 100644 --- a/apps/renterd/contexts/config/useResources.tsx +++ b/apps/renterd/contexts/config/useResources.tsx @@ -1,4 +1,3 @@ -import { minutesInMilliseconds } from '@siafoundation/design-system' import { useAutopilotConfig, useSettingContractSet, @@ -11,6 +10,7 @@ import { useSyncContractSet } from './useSyncContractSet' import { useAppSettings } from '@siafoundation/react-core' import { useSiaCentralHostsNetworkAverages } from '@siafoundation/sia-central-react' import { useApp } from '../app' +import { minutesInMilliseconds } from '@siafoundation/units' export function useResources() { const app = useApp() diff --git a/apps/renterd/contexts/contracts/index.tsx b/apps/renterd/contexts/contracts/index.tsx index 393cd24ce..b72277b50 100644 --- a/apps/renterd/contexts/contracts/index.tsx +++ b/apps/renterd/contexts/contracts/index.tsx @@ -4,7 +4,6 @@ import { useDatasetEmptyState, useClientFilters, useClientFilteredDataset, - daysInMilliseconds, } from '@siafoundation/design-system' import { useRouter } from 'next/router' import { @@ -38,6 +37,7 @@ import { defaultDatasetRefreshInterval } from '../../config/swr' import { useDataset } from './dataset' import { useFilteredStats } from './useFilteredStats' import { useAutopilot } from '../app/useAutopilot' +import { daysInMilliseconds } from '@siafoundation/units' const defaultLimit = 50 diff --git a/apps/renterd/contexts/contracts/useContractMetrics.tsx b/apps/renterd/contexts/contracts/useContractMetrics.tsx index 12abc9f01..ec73860c0 100644 --- a/apps/renterd/contexts/contracts/useContractMetrics.tsx +++ b/apps/renterd/contexts/contracts/useContractMetrics.tsx @@ -1,5 +1,4 @@ import { - daysInMilliseconds, Chart, formatChartData, computeChartStats, @@ -12,7 +11,7 @@ import { useMetricsContract } from '@siafoundation/renterd-react' import { useMemo } from 'react' import BigNumber from 'bignumber.js' import { ChartContractCategory, ChartContractKey } from './types' -import { humanSiacoin } from '@siafoundation/units' +import { humanSiacoin, daysInMilliseconds } from '@siafoundation/units' import { getTimeClampedToNearest5min } from './utils' export function useContractMetrics({ diff --git a/apps/renterd/contexts/contracts/useContractSetMetrics.tsx b/apps/renterd/contexts/contracts/useContractSetMetrics.tsx index cc01dea00..9cca2e5e3 100644 --- a/apps/renterd/contexts/contracts/useContractSetMetrics.tsx +++ b/apps/renterd/contexts/contracts/useContractSetMetrics.tsx @@ -1,5 +1,4 @@ import { - daysInMilliseconds, Chart, formatChartData, computeChartStats, @@ -13,6 +12,7 @@ import { import { useMemo } from 'react' import { ChartContractSetCategory, ChartContractSetKey } from './types' import { getTimeClampedToNearest5min } from './utils' +import { daysInMilliseconds } from '@siafoundation/units' export function useContractSetMetrics() { // don't use exact times, round to 5 minutes so that swr can cache diff --git a/apps/renterd/contexts/contracts/utils.ts b/apps/renterd/contexts/contracts/utils.ts index 6bf10df68..9a210521d 100644 --- a/apps/renterd/contexts/contracts/utils.ts +++ b/apps/renterd/contexts/contracts/utils.ts @@ -1,4 +1,4 @@ -import { minutesInMilliseconds } from '@siafoundation/design-system' +import { minutesInMilliseconds } from '@siafoundation/units' export function getTimeClampedToNearest5min(t: number) { const granularity = minutesInMilliseconds(5) diff --git a/apps/renterd/contexts/filesManager/uploads.tsx b/apps/renterd/contexts/filesManager/uploads.tsx index bcefdf0e7..5b7f2de96 100644 --- a/apps/renterd/contexts/filesManager/uploads.tsx +++ b/apps/renterd/contexts/filesManager/uploads.tsx @@ -1,7 +1,4 @@ -import { - minutesInMilliseconds, - triggerErrorToast, -} from '@siafoundation/design-system' +import { triggerErrorToast } from '@siafoundation/design-system' import { Bucket } from '@siafoundation/renterd-types' import { useBuckets, @@ -21,7 +18,7 @@ import { join, } from '../../lib/paths' import { MultipartUpload } from '../../lib/multipartUpload' -import { MiBToBytes } from '@siafoundation/units' +import { MiBToBytes, minutesInMilliseconds } from '@siafoundation/units' import { useMutate } from '@siafoundation/react-core' import { useWarnActiveUploadsOnClose } from './useWarnActiveUploadsOnClose' diff --git a/apps/renterd/contexts/transactions/index.tsx b/apps/renterd/contexts/transactions/index.tsx index 99189745a..4c64f6cad 100644 --- a/apps/renterd/contexts/transactions/index.tsx +++ b/apps/renterd/contexts/transactions/index.tsx @@ -1,8 +1,4 @@ -import { - daysInMilliseconds, - stripPrefix, - useDatasetEmptyState, -} from '@siafoundation/design-system' +import { stripPrefix, useDatasetEmptyState } from '@siafoundation/design-system' import { useMetricsWallet, useWalletPending, @@ -15,7 +11,11 @@ import { useRouter } from 'next/router' import { useSiascanUrl } from '../../hooks/useSiascanUrl' import { Transaction } from '@siafoundation/types' import { defaultDatasetRefreshInterval } from '../../config/swr' -import { TxType, getTransactionType } from '@siafoundation/units' +import { + TxType, + getTransactionType, + daysInMilliseconds, +} from '@siafoundation/units' const defaultLimit = 50 const filters = [] diff --git a/apps/renterd/hooks/useSyncStatus.ts b/apps/renterd/hooks/useSyncStatus.ts index c2d896a28..053d65309 100644 --- a/apps/renterd/hooks/useSyncStatus.ts +++ b/apps/renterd/hooks/useSyncStatus.ts @@ -1,4 +1,4 @@ -import { secondsInMilliseconds } from '@siafoundation/design-system' +import { secondsInMilliseconds } from '@siafoundation/units' import { useAppSettings } from '@siafoundation/react-core' import { useConsensusState, diff --git a/apps/walletd/config/swr.ts b/apps/walletd/config/swr.ts index 23d7e1297..6e3827779 100644 --- a/apps/walletd/config/swr.ts +++ b/apps/walletd/config/swr.ts @@ -1,3 +1,3 @@ -import { secondsInMilliseconds } from '@siafoundation/design-system' +import { secondsInMilliseconds } from '@siafoundation/units' export const defaultDatasetRefreshInterval = secondsInMilliseconds(15) diff --git a/apps/walletd/contexts/wallets/useWalletSeedCache.ts b/apps/walletd/contexts/wallets/useWalletSeedCache.ts index 941a2ed72..2da5cb8ef 100644 --- a/apps/walletd/contexts/wallets/useWalletSeedCache.ts +++ b/apps/walletd/contexts/wallets/useWalletSeedCache.ts @@ -1,4 +1,4 @@ -import { minutesInMilliseconds } from '@siafoundation/design-system' +import { minutesInMilliseconds } from '@siafoundation/units' import { routes } from '../../config/routes' import { useRouter } from 'next/router' import { useCallback, useEffect, useMemo, useState } from 'react' diff --git a/apps/walletd/dialogs/WalletdSettingsDialog.tsx b/apps/walletd/dialogs/WalletdSettingsDialog.tsx index 2c2216708..8704600e1 100644 --- a/apps/walletd/dialogs/WalletdSettingsDialog.tsx +++ b/apps/walletd/dialogs/WalletdSettingsDialog.tsx @@ -7,10 +7,10 @@ import { Option, Paragraph, SettingsDialog, - minutesInMilliseconds, } from '@siafoundation/design-system' import { Information16 } from '@siafoundation/react-icons' import { useWallets } from '../contexts/wallets' +import { minutesInMilliseconds } from '@siafoundation/units' export type WalletdSettingsDialogParams = never diff --git a/apps/walletd/hooks/useSyncStatus.ts b/apps/walletd/hooks/useSyncStatus.ts index a142bf87c..234a4415a 100644 --- a/apps/walletd/hooks/useSyncStatus.ts +++ b/apps/walletd/hooks/useSyncStatus.ts @@ -1,4 +1,4 @@ -import { hoursInMilliseconds } from '@siafoundation/design-system' +import { hoursInMilliseconds } from '@siafoundation/units' import { useAppSettings } from '@siafoundation/react-core' import { ConsensusState } from '@siafoundation/types' import { diff --git a/apps/website/components/Map/Globe.tsx b/apps/website/components/Map/Globe.tsx index 4f38b92c7..d2504e1d9 100644 --- a/apps/website/components/Map/Globe.tsx +++ b/apps/website/components/Map/Globe.tsx @@ -2,14 +2,13 @@ import { useEffect, useRef, useCallback, useMemo } from 'react' import { GlobeMethods } from 'react-globe.gl' import { getHostLabel } from './utils' import { useElementSize } from 'usehooks-ts' -import { useTryUntil } from '@siafoundation/react-core' +import { useTryUntil, useExchangeRate } from '@siafoundation/react-core' import earthDarkContrast from '../../assets/earth-dark-contrast.png' import earthTopology from '../../assets/earth-topology.png' import nightSky from '../../assets/night-sky.png' import { GlobeDyn } from './GlobeDyn' import { useDecRoutes } from './useRoutes' import { SiaCentralPartialHost } from '../../content/geoHosts' -import { useExchangeRate } from '@siafoundation/design-system' export type Commands = { moveToLocation: ( diff --git a/apps/website/content/articles.ts b/apps/website/content/articles.ts index 9b3d66ae5..b5340192b 100644 --- a/apps/website/content/articles.ts +++ b/apps/website/content/articles.ts @@ -1,7 +1,7 @@ import { addNewTab } from '../lib/utils' -import { getMinutesInSeconds } from '../lib/time' import { getCacheValue } from '../lib/cache' import { fetchArticlesByTag } from '@siafoundation/data-sources' +import { minutesInSeconds } from '@siafoundation/units' type Article = { title: string @@ -9,7 +9,7 @@ type Article = { link: string } -const maxAge = getMinutesInSeconds(5) +const maxAge = minutesInSeconds(5) export async function getTutorialArticles(limit?: number) { const articles = await getCacheValue( diff --git a/apps/website/content/exchangeRates.ts b/apps/website/content/exchangeRates.ts index 9d38a0fc8..8cdd2b8d3 100644 --- a/apps/website/content/exchangeRates.ts +++ b/apps/website/content/exchangeRates.ts @@ -1,9 +1,9 @@ import { getCacheValue } from '../lib/cache' -import { getMinutesInSeconds } from '../lib/time' import { siaCentral } from '../config/siaCentral' import { to } from '@siafoundation/request' +import { minutesInSeconds } from '@siafoundation/units' -const maxAge = getMinutesInSeconds(5) +const maxAge = minutesInSeconds(5) export async function getExchangeRates() { return getCacheValue( diff --git a/apps/website/content/feed.ts b/apps/website/content/feed.ts index 4968cfc65..309fe5c2a 100644 --- a/apps/website/content/feed.ts +++ b/apps/website/content/feed.ts @@ -1,5 +1,5 @@ +import { minutesInSeconds } from '@siafoundation/units' import { getCacheValue } from '../lib/cache' -import { getMinutesInSeconds } from '../lib/time' import { addNewTab } from '../lib/utils' import { fetchAllFeedItems } from '@siafoundation/data-sources' @@ -18,7 +18,7 @@ type FeedItem = { newTab?: boolean } -const maxAge = getMinutesInSeconds(5) +const maxAge = minutesInSeconds(5) async function fetchFeedContent( tags: Tag[], diff --git a/apps/website/content/geoHosts.ts b/apps/website/content/geoHosts.ts index 365537e07..5c3f5bea2 100644 --- a/apps/website/content/geoHosts.ts +++ b/apps/website/content/geoHosts.ts @@ -1,10 +1,10 @@ import { SiaCentralHost } from '@siafoundation/sia-central-types' import { getCacheValue } from '../lib/cache' -import { getMinutesInSeconds } from '../lib/time' import { siaCentral } from '../config/siaCentral' import { to } from '@siafoundation/request' +import { minutesInSeconds } from '@siafoundation/units' -const maxAge = getMinutesInSeconds(5) +const maxAge = minutesInSeconds(5) const maxHosts = 1000 const minDegreesApart = 1 diff --git a/apps/website/content/grantCommittee.ts b/apps/website/content/grantCommittee.ts index 5da958e42..0faf7070b 100644 --- a/apps/website/content/grantCommittee.ts +++ b/apps/website/content/grantCommittee.ts @@ -1,8 +1,8 @@ import { fetchGrantCommittee } from '@siafoundation/data-sources' import { getCacheValue } from '../lib/cache' -import { getMinutesInSeconds } from '../lib/time' +import { minutesInSeconds } from '@siafoundation/units' -const maxAge = getMinutesInSeconds(5) +const maxAge = minutesInSeconds(5) export async function getGrantCommittee() { return getCacheValue('grantCommittee', fetchGrantCommittee, maxAge) diff --git a/apps/website/content/projects.ts b/apps/website/content/projects.ts index 2a98de7fe..9b2bd3313 100644 --- a/apps/website/content/projects.ts +++ b/apps/website/content/projects.ts @@ -1,10 +1,10 @@ import { ContentItemProps } from '@siafoundation/design-system' import { addNewTab } from '../lib/utils' -import { getMinutesInSeconds } from '../lib/time' +import { minutesInSeconds } from '@siafoundation/units' import { getCacheValue } from '../lib/cache' import { fetchProjects } from '@siafoundation/data-sources' -const maxAge = getMinutesInSeconds(5) +const maxAge = minutesInSeconds(5) export async function getProjects( tag: string | null, diff --git a/apps/website/content/prs.ts b/apps/website/content/prs.ts index 45b82e1c4..026c706f4 100644 --- a/apps/website/content/prs.ts +++ b/apps/website/content/prs.ts @@ -2,10 +2,10 @@ import { getGitHubClosedPRs } from '@siafoundation/data-sources' import { MDXRemoteSerializeResult } from 'next-mdx-remote' import { serialize } from 'next-mdx-remote/serialize' import { getCacheValue } from '../lib/cache' -import { getMinutesInSeconds } from '../lib/time' +import { minutesInSeconds } from '@siafoundation/units' import remarkGfm from 'remark-gfm' -const maxAge = getMinutesInSeconds(5) +const maxAge = minutesInSeconds(5) export async function getPrs() { return getCacheValue( diff --git a/apps/website/content/releases.ts b/apps/website/content/releases.ts index f4b797826..7e23b7602 100644 --- a/apps/website/content/releases.ts +++ b/apps/website/content/releases.ts @@ -7,9 +7,9 @@ import { getGitHubWalletdLatestDesktopRelease, } from '@siafoundation/data-sources' import { getCacheValue } from '../lib/cache' -import { getMinutesInSeconds } from '../lib/time' +import { minutesInSeconds } from '@siafoundation/units' -const maxAge = getMinutesInSeconds(5) +const maxAge = minutesInSeconds(5) export async function getRenterdLatestDaemonRelease() { return getCacheValue( diff --git a/apps/website/content/reports.ts b/apps/website/content/reports.ts index 1a0443e6d..f09bca35a 100644 --- a/apps/website/content/reports.ts +++ b/apps/website/content/reports.ts @@ -1,7 +1,7 @@ import fs from 'fs' import { toPairs } from '@technically/lodash' import { webLinks } from '@siafoundation/design-system' -import { getMinutesInSeconds } from '../lib/time' +import { minutesInSeconds } from '@siafoundation/units' import { getCacheValue } from '../lib/cache' import { getAssetPath } from '@siafoundation/data-sources' @@ -12,7 +12,7 @@ type Report = { } type ReportPair = [string, Report[]] -const maxAge = getMinutesInSeconds(5) +const maxAge = minutesInSeconds(5) export async function getReports(): Promise { return getCacheValue('transparencyReports', async () => readReports(), maxAge) diff --git a/apps/website/content/stats.ts b/apps/website/content/stats.ts index fdd22480e..9a9f69ec6 100644 --- a/apps/website/content/stats.ts +++ b/apps/website/content/stats.ts @@ -2,11 +2,11 @@ import { getGitHub } from '@siafoundation/data-sources' import { humanBytes, humanNumber } from '@siafoundation/units' import { AsyncReturnType } from '../lib/types' import { getCacheValue } from '../lib/cache' -import { getMinutesInSeconds } from '../lib/time' +import { minutesInSeconds } from '@siafoundation/units' import { siaCentral } from '../config/siaCentral' import { to } from '@siafoundation/request' -const maxAge = getMinutesInSeconds(5) +const maxAge = minutesInSeconds(5) export async function getStats() { return getCacheValue('stats', () => readStats(), maxAge) diff --git a/apps/website/content/team.ts b/apps/website/content/team.ts index 5b7a6086c..6eefc7142 100644 --- a/apps/website/content/team.ts +++ b/apps/website/content/team.ts @@ -1,8 +1,8 @@ import { fetchTeam } from '@siafoundation/data-sources' import { getCacheValue } from '../lib/cache' -import { getMinutesInSeconds } from '../lib/time' +import { minutesInSeconds } from '@siafoundation/units' -const maxAge = getMinutesInSeconds(5) +const maxAge = minutesInSeconds(5) export async function getTeam() { return getCacheValue('team', fetchTeam, maxAge) diff --git a/apps/website/lib/time.ts b/apps/website/lib/time.ts deleted file mode 100644 index c462cede4..000000000 --- a/apps/website/lib/time.ts +++ /dev/null @@ -1,7 +0,0 @@ -export function getDaysInSeconds(days: number) { - return days * 24 * 60 * 60 -} - -export function getMinutesInSeconds(minutes: number) { - return minutes * 60 -} diff --git a/apps/website/pages/about-sia-foundation/index.tsx b/apps/website/pages/about-sia-foundation/index.tsx index 29326b802..5f3db5b70 100644 --- a/apps/website/pages/about-sia-foundation/index.tsx +++ b/apps/website/pages/about-sia-foundation/index.tsx @@ -17,7 +17,7 @@ import { } from '@siafoundation/react-icons' import { Layout } from '../../components/Layout' import { routes } from '../../config/routes' -import { getMinutesInSeconds } from '../../lib/time' +import { minutesInSeconds } from '@siafoundation/units' import { AsyncReturnType } from '../../lib/types' import { getReports } from '../../content/reports' import { getStats } from '../../content/stats' @@ -230,7 +230,7 @@ export async function getStaticProps() { '/api/stats': stats, }, }, - revalidate: getMinutesInSeconds(5), + revalidate: minutesInSeconds(5), } } diff --git a/apps/website/pages/activity/index.tsx b/apps/website/pages/activity/index.tsx index cae2da953..dff3fb09f 100644 --- a/apps/website/pages/activity/index.tsx +++ b/apps/website/pages/activity/index.tsx @@ -3,7 +3,7 @@ import { Layout } from '../../components/Layout' import { routes } from '../../config/routes' import { getStats } from '../../content/stats' import { AsyncReturnType } from '../../lib/types' -import { getMinutesInSeconds } from '../../lib/time' +import { minutesInSeconds } from '@siafoundation/units' import { SectionSolid } from '../../components/SectionSolid' import { getPrs } from '../../content/prs' import { GitHubActivity } from '../../components/GitHubActivity' @@ -52,6 +52,6 @@ export async function getStaticProps() { '/api/stats': stats, }, }, - revalidate: getMinutesInSeconds(5), + revalidate: minutesInSeconds(5), } } diff --git a/apps/website/pages/api/news.ts b/apps/website/pages/api/news.ts index cbcd33e90..a3a5e90dc 100644 --- a/apps/website/pages/api/news.ts +++ b/apps/website/pages/api/news.ts @@ -1,7 +1,7 @@ -import { getMinutesInSeconds } from '../../lib/time' +import { minutesInSeconds } from '@siafoundation/units' import { getNewsFeed } from '../../content/feed' -const maxAge = getMinutesInSeconds(5) +const maxAge = minutesInSeconds(5) export default async function handler(req, res) { res.setHeader('Cache-Control', `s-maxage=${maxAge}`) diff --git a/apps/website/pages/api/stats.ts b/apps/website/pages/api/stats.ts index cf700d5c4..f145cc839 100644 --- a/apps/website/pages/api/stats.ts +++ b/apps/website/pages/api/stats.ts @@ -1,7 +1,7 @@ -import { getMinutesInSeconds } from '../../lib/time' +import { minutesInSeconds } from '@siafoundation/units' import { getStats } from '../../content/stats' -const maxAge = getMinutesInSeconds(5) +const maxAge = minutesInSeconds(5) export default async function handler(req, res) { res.setHeader('Cache-Control', `s-maxage=${maxAge}`) diff --git a/apps/website/pages/community-ecosystem/index.tsx b/apps/website/pages/community-ecosystem/index.tsx index 1b154d606..ead21e3b7 100644 --- a/apps/website/pages/community-ecosystem/index.tsx +++ b/apps/website/pages/community-ecosystem/index.tsx @@ -11,7 +11,7 @@ import { getProjects } from '../../content/projects' import { getStats } from '../../content/stats' import { AsyncReturnType } from '../../lib/types' import { textContent } from '../../lib/utils' -import { getMinutesInSeconds } from '../../lib/time' +import { minutesInSeconds } from '@siafoundation/units' import { SectionTransparent } from '../../components/SectionTransparent' import { SectionGradient } from '../../components/SectionGradient' import { backgrounds, previews } from '../../content/assets' @@ -128,6 +128,6 @@ export async function getStaticProps() { '/api/stats': stats, }, }, - revalidate: getMinutesInSeconds(5), + revalidate: minutesInSeconds(5), } } diff --git a/apps/website/pages/grants/index.tsx b/apps/website/pages/grants/index.tsx index 592bf8961..60b051244 100644 --- a/apps/website/pages/grants/index.tsx +++ b/apps/website/pages/grants/index.tsx @@ -11,7 +11,7 @@ import { getProjects } from '../../content/projects' import { getStats } from '../../content/stats' import { textContent } from '../../lib/utils' import { AsyncReturnType } from '../../lib/types' -import { getMinutesInSeconds } from '../../lib/time' +import { minutesInSeconds } from '@siafoundation/units' import { getGrantCommittee } from '../../content/grantCommittee' import { SectionTransparent } from '../../components/SectionTransparent' import { SectionGradient } from '../../components/SectionGradient' @@ -202,6 +202,6 @@ export async function getStaticProps() { '/api/stats': stats, }, }, - revalidate: getMinutesInSeconds(5), + revalidate: minutesInSeconds(5), } } diff --git a/apps/website/pages/host/index.tsx b/apps/website/pages/host/index.tsx index aacfe6965..294283de9 100644 --- a/apps/website/pages/host/index.tsx +++ b/apps/website/pages/host/index.tsx @@ -7,7 +7,7 @@ import { } from '@siafoundation/design-system' import { Layout } from '../../components/Layout' import { routes } from '../../config/routes' -import { getMinutesInSeconds } from '../../lib/time' +import { minutesInSeconds } from '@siafoundation/units' import { getFeedContent } from '../../content/feed' import { AsyncReturnType } from '../../lib/types' import { getProjects } from '../../content/projects' @@ -181,6 +181,6 @@ export async function getStaticProps() { return { props, - revalidate: getMinutesInSeconds(5), + revalidate: minutesInSeconds(5), } } diff --git a/apps/website/pages/hosting-best-practices/index.tsx b/apps/website/pages/hosting-best-practices/index.tsx index 34b92675a..1ba21fe4b 100644 --- a/apps/website/pages/hosting-best-practices/index.tsx +++ b/apps/website/pages/hosting-best-practices/index.tsx @@ -3,7 +3,7 @@ import { Layout } from '../../components/Layout' import { routes } from '../../config/routes' import { getStats } from '../../content/stats' import { AsyncReturnType } from '../../lib/types' -import { getMinutesInSeconds } from '../../lib/time' +import { minutesInSeconds } from '@siafoundation/units' import { SectionSolid } from '../../components/SectionSolid' import { format } from 'date-fns' import { MDXRemote } from 'next-mdx-remote' @@ -74,6 +74,6 @@ export async function getStaticProps() { '/api/stats': stats, }, }, - revalidate: getMinutesInSeconds(5), + revalidate: minutesInSeconds(5), } } diff --git a/apps/website/pages/index.tsx b/apps/website/pages/index.tsx index dc4c0cbdc..44a10f62a 100644 --- a/apps/website/pages/index.tsx +++ b/apps/website/pages/index.tsx @@ -23,7 +23,7 @@ import { CalloutProject } from '../components/CalloutProject' import { getGeoHosts } from '../content/geoHosts' import { getExchangeRates } from '../content/exchangeRates' import { getStats } from '../content/stats' -import { getMinutesInSeconds } from '../lib/time' +import { minutesInSeconds } from '@siafoundation/units' type Props = AsyncReturnType['props'] @@ -298,6 +298,6 @@ export async function getStaticProps() { return { props, - revalidate: getMinutesInSeconds(5), + revalidate: minutesInSeconds(5), } } diff --git a/apps/website/pages/learn/index.tsx b/apps/website/pages/learn/index.tsx index 18d69f996..8978d105a 100644 --- a/apps/website/pages/learn/index.tsx +++ b/apps/website/pages/learn/index.tsx @@ -9,7 +9,7 @@ import { import { Layout } from '../../components/Layout' import { routes } from '../../config/routes' import { getStats } from '../../content/stats' -import { getMinutesInSeconds } from '../../lib/time' +import { minutesInSeconds } from '@siafoundation/units' import { textContent } from '../../lib/utils' import { getTutorialArticles } from '../../content/articles' import { AsyncReturnType } from '../../lib/types' @@ -326,6 +326,6 @@ export async function getStaticProps() { '/api/stats': stats, }, }, - revalidate: getMinutesInSeconds(5), + revalidate: minutesInSeconds(5), } } diff --git a/apps/website/pages/letter/index.tsx b/apps/website/pages/letter/index.tsx index 38e77b5ee..baee6cce5 100644 --- a/apps/website/pages/letter/index.tsx +++ b/apps/website/pages/letter/index.tsx @@ -3,7 +3,7 @@ import { Layout } from '../../components/Layout' import { routes } from '../../config/routes' import { getStats } from '../../content/stats' import { AsyncReturnType } from '../../lib/types' -import { getMinutesInSeconds } from '../../lib/time' +import { minutesInSeconds } from '@siafoundation/units' import { SectionSolid } from '../../components/SectionSolid' import { MDXRemote } from 'next-mdx-remote' import { components } from '../../config/mdx' @@ -57,6 +57,6 @@ export async function getStaticProps() { '/api/stats': stats, }, }, - revalidate: getMinutesInSeconds(5), + revalidate: minutesInSeconds(5), } } diff --git a/apps/website/pages/map.tsx b/apps/website/pages/map.tsx index ba5680397..795493548 100644 --- a/apps/website/pages/map.tsx +++ b/apps/website/pages/map.tsx @@ -1,7 +1,7 @@ import { AsyncReturnType } from '../lib/types' import { getGeoHosts } from '../content/geoHosts' import { getExchangeRates } from '../content/exchangeRates' -import { getMinutesInSeconds } from '../lib/time' +import { minutesInSeconds } from '@siafoundation/units' import { Map } from '../components/Map' import { getStats } from '../content/stats' @@ -26,6 +26,6 @@ export async function getStaticProps() { return { props, - revalidate: getMinutesInSeconds(5), + revalidate: minutesInSeconds(5), } } diff --git a/apps/website/pages/markdown/index.tsx b/apps/website/pages/markdown/index.tsx index 028d019fe..fc36a35f2 100644 --- a/apps/website/pages/markdown/index.tsx +++ b/apps/website/pages/markdown/index.tsx @@ -3,7 +3,7 @@ import { Layout } from '../../components/Layout' import { routes } from '../../config/routes' import { getStats } from '../../content/stats' import { AsyncReturnType } from '../../lib/types' -import { getMinutesInSeconds } from '../../lib/time' +import { minutesInSeconds } from '@siafoundation/units' import { SectionSolid } from '../../components/SectionSolid' import { format } from 'date-fns' import { MDXRemote } from 'next-mdx-remote' @@ -62,6 +62,6 @@ export async function getStaticProps() { '/api/stats': stats, }, }, - revalidate: getMinutesInSeconds(5), + revalidate: minutesInSeconds(5), } } diff --git a/apps/website/pages/news/index.tsx b/apps/website/pages/news/index.tsx index 57307b8b8..862342d08 100644 --- a/apps/website/pages/news/index.tsx +++ b/apps/website/pages/news/index.tsx @@ -9,7 +9,7 @@ import { getStats } from '../../content/stats' import useSWR from 'swr' import { useRouter } from 'next/router' import { getNewsFeed } from '../../content/feed' -import { getMinutesInSeconds } from '../../lib/time' +import { minutesInSeconds } from '@siafoundation/units' import { SectionSolid } from '../../components/SectionSolid' import { backgrounds, previews } from '../../content/assets' import { SectionTransparent } from '../../components/SectionTransparent' @@ -74,7 +74,7 @@ export async function getStaticProps() { '/api/stats': stats, }, }, - revalidate: getMinutesInSeconds(5), + revalidate: minutesInSeconds(5), } } diff --git a/apps/website/pages/privacy-policy/index.tsx b/apps/website/pages/privacy-policy/index.tsx index db063ec4a..3603e650f 100644 --- a/apps/website/pages/privacy-policy/index.tsx +++ b/apps/website/pages/privacy-policy/index.tsx @@ -3,7 +3,7 @@ import { Layout } from '../../components/Layout' import { routes } from '../../config/routes' import { getStats } from '../../content/stats' import { AsyncReturnType } from '../../lib/types' -import { getMinutesInSeconds } from '../../lib/time' +import { minutesInSeconds } from '@siafoundation/units' import { SectionSolid } from '../../components/SectionSolid' import { format } from 'date-fns' import { MDXRemote } from 'next-mdx-remote' @@ -62,6 +62,6 @@ export async function getStaticProps() { '/api/stats': stats, }, }, - revalidate: getMinutesInSeconds(5), + revalidate: minutesInSeconds(5), } } diff --git a/apps/website/pages/rent/index.tsx b/apps/website/pages/rent/index.tsx index 9e169e320..54f688012 100644 --- a/apps/website/pages/rent/index.tsx +++ b/apps/website/pages/rent/index.tsx @@ -7,7 +7,7 @@ import { } from '@siafoundation/design-system' import { Layout } from '../../components/Layout' import { routes } from '../../config/routes' -import { getMinutesInSeconds } from '../../lib/time' +import { minutesInSeconds } from '@siafoundation/units' import { getFeedContent } from '../../content/feed' import { AsyncReturnType } from '../../lib/types' import { getProjects } from '../../content/projects' @@ -179,6 +179,6 @@ export async function getStaticProps() { return { props, - revalidate: getMinutesInSeconds(5), + revalidate: minutesInSeconds(5), } } diff --git a/apps/website/pages/roadmap/index.tsx b/apps/website/pages/roadmap/index.tsx index 7bf64a9f5..8ccad6dd8 100644 --- a/apps/website/pages/roadmap/index.tsx +++ b/apps/website/pages/roadmap/index.tsx @@ -9,7 +9,7 @@ import { Layout } from '../../components/Layout' import { routes } from '../../config/routes' import { getStats } from '../../content/stats' import { AsyncReturnType } from '../../lib/types' -import { getMinutesInSeconds } from '../../lib/time' +import { minutesInSeconds } from '@siafoundation/units' import { SectionSolid } from '../../components/SectionSolid' import { MDXRemote } from 'next-mdx-remote' import { components } from '../../config/mdx' @@ -88,6 +88,6 @@ export async function getStaticProps() { '/api/stats': stats, }, }, - revalidate: getMinutesInSeconds(5), + revalidate: minutesInSeconds(5), } } diff --git a/apps/website/pages/software/hostd.tsx b/apps/website/pages/software/hostd.tsx index b10ed1016..e00f7da91 100644 --- a/apps/website/pages/software/hostd.tsx +++ b/apps/website/pages/software/hostd.tsx @@ -8,7 +8,7 @@ import { } from '@siafoundation/design-system' import { Layout } from '../../components/Layout' import { routes } from '../../config/routes' -import { getMinutesInSeconds } from '../../lib/time' +import { minutesInSeconds } from '@siafoundation/units' import { getFeedContent } from '../../content/feed' import { AsyncReturnType } from '../../lib/types' import { getProjects } from '../../content/projects' @@ -155,6 +155,6 @@ export async function getStaticProps() { return { props, - revalidate: getMinutesInSeconds(5), + revalidate: minutesInSeconds(5), } } diff --git a/apps/website/pages/software/renterd.tsx b/apps/website/pages/software/renterd.tsx index cef72e751..c4d4bc74f 100644 --- a/apps/website/pages/software/renterd.tsx +++ b/apps/website/pages/software/renterd.tsx @@ -10,7 +10,7 @@ import { import { Layout } from '../../components/Layout' import { CarouselRenterd } from '../../components/CarouselRenterd' import { routes } from '../../config/routes' -import { getMinutesInSeconds } from '../../lib/time' +import { minutesInSeconds } from '@siafoundation/units' import { getFeedContent } from '../../content/feed' import { AsyncReturnType } from '../../lib/types' import { getProjects } from '../../content/projects' @@ -310,6 +310,6 @@ export async function getStaticProps() { return { props, - revalidate: getMinutesInSeconds(5), + revalidate: minutesInSeconds(5), } } diff --git a/apps/website/pages/software/walletd.tsx b/apps/website/pages/software/walletd.tsx index 08cb3519e..2f1be3fa9 100644 --- a/apps/website/pages/software/walletd.tsx +++ b/apps/website/pages/software/walletd.tsx @@ -8,7 +8,7 @@ import { } from '@siafoundation/design-system' import { Layout } from '../../components/Layout' import { routes } from '../../config/routes' -import { getMinutesInSeconds } from '../../lib/time' +import { minutesInSeconds } from '@siafoundation/units' import { getFeedContent } from '../../content/feed' import { AsyncReturnType } from '../../lib/types' import { getProjects } from '../../content/projects' @@ -157,6 +157,6 @@ export async function getStaticProps() { return { props, - revalidate: getMinutesInSeconds(5), + revalidate: minutesInSeconds(5), } } diff --git a/apps/website/pages/terms-of-service/index.tsx b/apps/website/pages/terms-of-service/index.tsx index 9d1f519b5..7e49bbd4f 100644 --- a/apps/website/pages/terms-of-service/index.tsx +++ b/apps/website/pages/terms-of-service/index.tsx @@ -3,7 +3,7 @@ import { Layout } from '../../components/Layout' import { routes } from '../../config/routes' import { getStats } from '../../content/stats' import { AsyncReturnType } from '../../lib/types' -import { getMinutesInSeconds } from '../../lib/time' +import { minutesInSeconds } from '@siafoundation/units' import { SectionSolid } from '../../components/SectionSolid' import { format } from 'date-fns' import { MDXRemote } from 'next-mdx-remote' @@ -62,6 +62,6 @@ export async function getStaticProps() { '/api/stats': stats, }, }, - revalidate: getMinutesInSeconds(5), + revalidate: minutesInSeconds(5), } } diff --git a/apps/website/pages/wallet/index.tsx b/apps/website/pages/wallet/index.tsx index 46c859a28..a7ab8c4c1 100644 --- a/apps/website/pages/wallet/index.tsx +++ b/apps/website/pages/wallet/index.tsx @@ -7,7 +7,7 @@ import { } from '@siafoundation/design-system' import { Layout } from '../../components/Layout' import { routes } from '../../config/routes' -import { getMinutesInSeconds } from '../../lib/time' +import { minutesInSeconds } from '@siafoundation/units' import { getFeedContent } from '../../content/feed' import { AsyncReturnType } from '../../lib/types' import { getProjects } from '../../content/projects' @@ -164,6 +164,6 @@ export async function getStaticProps() { return { props, - revalidate: getMinutesInSeconds(5), + revalidate: minutesInSeconds(5), } } diff --git a/libs/design-system/src/app/SettingsDialog.tsx b/libs/design-system/src/app/SettingsDialog.tsx index 9ec5faf20..179a66cad 100644 --- a/libs/design-system/src/app/SettingsDialog.tsx +++ b/libs/design-system/src/app/SettingsDialog.tsx @@ -16,10 +16,10 @@ import { ThemeRadio } from '../components/ThemeRadio' import { webLinks } from '../data/webLinks' import { useAppSettings } from '@siafoundation/react-core' import { Dialog } from '../core/Dialog' -import { minutesInMilliseconds } from '../lib/time' import { CurrencyFiatSelector } from './CurrencyFiatSelector' import { CurrencyDisplaySelector } from './CurrencyDisplaySelector' import { ValueCopyable } from '../components/ValueCopyable' +import { minutesInMilliseconds } from '@siafoundation/units' type Props = { open: boolean diff --git a/libs/design-system/src/components/ChartBrush/index.tsx b/libs/design-system/src/components/ChartBrush/index.tsx index 293635e6d..01984fe73 100644 --- a/libs/design-system/src/components/ChartBrush/index.tsx +++ b/libs/design-system/src/components/ChartBrush/index.tsx @@ -9,7 +9,7 @@ import BaseBrush from '@visx/brush/lib/BaseBrush' import { ParentSize } from '@visx/responsive' import { AreaChart } from '../ChartTimeValue/AreaChart' import { Panel } from '../../core/Panel' -import { daysInMilliseconds } from '../../lib/time' +import { daysInMilliseconds } from '@siafoundation/units' const accentColor = 'var(--colors-accent9)' const patternColor = 'var(--colors-accent9)' diff --git a/libs/design-system/src/components/ChartXY/useChartXY.tsx b/libs/design-system/src/components/ChartXY/useChartXY.tsx index 508ef625b..9d926783f 100644 --- a/libs/design-system/src/components/ChartXY/useChartXY.tsx +++ b/libs/design-system/src/components/ChartXY/useChartXY.tsx @@ -17,7 +17,7 @@ import { CurveType, StackOffset, } from './types' -import { daysInMilliseconds } from '../../lib/time' +import { daysInMilliseconds } from '@siafoundation/units' import { usePrefersReducedMotion } from '@siafoundation/react-core' import useLocalStorageState from 'use-local-storage-state' diff --git a/libs/design-system/src/components/ValueFiat.tsx b/libs/design-system/src/components/ValueFiat.tsx index 463fce132..436b4fdc0 100644 --- a/libs/design-system/src/components/ValueFiat.tsx +++ b/libs/design-system/src/components/ValueFiat.tsx @@ -3,7 +3,7 @@ import { Text } from '../core/Text' import { Tooltip } from '../core/Tooltip' import BigNumber from 'bignumber.js' -import { useActiveExchangeRate } from '../hooks/useExchangeRate' +import { useActiveExchangeRate } from '@siafoundation/react-core' type Props = { size?: React.ComponentProps['size'] diff --git a/libs/design-system/src/components/ValueScFiat.tsx b/libs/design-system/src/components/ValueScFiat.tsx index 56ef2012b..21724f137 100644 --- a/libs/design-system/src/components/ValueScFiat.tsx +++ b/libs/design-system/src/components/ValueScFiat.tsx @@ -4,10 +4,12 @@ import { Text } from '../core/Text' import BigNumber from 'bignumber.js' import { ValueSc } from './ValueSc' import { ValueFiat } from './ValueFiat' -import { useAppSettings } from '@siafoundation/react-core' +import { + useAppSettings, + useActiveExchangeRate, +} from '@siafoundation/react-core' import { useMemo } from 'react' import { Tooltip } from '../core/Tooltip' -import { useActiveExchangeRate } from '../hooks/useExchangeRate' type Props = { size?: React.ComponentProps['size'] diff --git a/libs/design-system/src/core/SiacoinField.tsx b/libs/design-system/src/core/SiacoinField.tsx index e1b82f898..9fc9f7420 100644 --- a/libs/design-system/src/core/SiacoinField.tsx +++ b/libs/design-system/src/core/SiacoinField.tsx @@ -1,12 +1,14 @@ 'use client' -import { useAppSettings } from '@siafoundation/react-core' +import { + useAppSettings, + useActiveExchangeRate, +} from '@siafoundation/react-core' import { useCallback, useEffect, useMemo, useState } from 'react' import BigNumber from 'bignumber.js' import { cx } from 'class-variance-authority' import { toFixedMaxString } from '../lib/numbers' import { BaseNumberField } from './BaseNumberField' -import { useActiveExchangeRate } from '../hooks/useExchangeRate' type Props = Omit< React.ComponentProps, diff --git a/libs/design-system/src/form/ConfigurationFiat.tsx b/libs/design-system/src/form/ConfigurationFiat.tsx index de3bc94f9..c4864aac2 100644 --- a/libs/design-system/src/form/ConfigurationFiat.tsx +++ b/libs/design-system/src/form/ConfigurationFiat.tsx @@ -4,9 +4,8 @@ import { FieldProps } from './configurationFields' import { FieldFiat } from './FieldFiat' import { TipNumber } from './TipNumber' import { useFormSetField } from './useFormSetField' -import { CurrencyId } from '@siafoundation/react-core' +import { CurrencyId, useExchangeRate } from '@siafoundation/react-core' import BigNumber from 'bignumber.js' -import { useSiascanExchangeRate } from '../hooks/useExchangeRate' import { useMemo } from 'react' export function ConfigurationFiat< @@ -37,7 +36,7 @@ export function ConfigurationFiat< fields, name, }) - const exchangeRate = useSiascanExchangeRate({ + const exchangeRate = useExchangeRate({ currency: currency || undefined, }) const rate = exchangeRate.rate diff --git a/libs/design-system/src/form/FieldFiat.tsx b/libs/design-system/src/form/FieldFiat.tsx index a2095af9c..380603fb3 100644 --- a/libs/design-system/src/form/FieldFiat.tsx +++ b/libs/design-system/src/form/FieldFiat.tsx @@ -7,12 +7,15 @@ import { ChartArea16 } from '@siafoundation/react-icons' import { Panel } from '../core/Panel' import { Text } from '../core/Text' import { toHastings } from '@siafoundation/units' -import { CurrencyId, currencyOptions } from '@siafoundation/react-core' +import { + CurrencyId, + currencyOptions, + useExchangeRate, +} from '@siafoundation/react-core' import { useMemo } from 'react' import { Tooltip } from '../core/Tooltip' import { ValueSc } from '../components/ValueSc' import { cx } from 'class-variance-authority' -import { useSiascanExchangeRate } from '../hooks/useExchangeRate' export function FieldFiat< Values extends FieldValues, @@ -29,7 +32,7 @@ export function FieldFiat< currency: CurrencyId | '' group?: boolean }) { - const exchangeRate = useSiascanExchangeRate({ + const exchangeRate = useExchangeRate({ currency: currency || undefined, }) const rate = exchangeRate.rate diff --git a/libs/design-system/src/hooks/useSiacoinFiat.tsx b/libs/design-system/src/hooks/useSiacoinFiat.tsx index 4e42e525c..8fe87dd2b 100644 --- a/libs/design-system/src/hooks/useSiacoinFiat.tsx +++ b/libs/design-system/src/hooks/useSiacoinFiat.tsx @@ -1,7 +1,10 @@ -import { CurrencyOption, useAppSettings } from '@siafoundation/react-core' +import { + CurrencyOption, + useAppSettings, + useExchangeRate, +} from '@siafoundation/react-core' import { useMemo } from 'react' import BigNumber from 'bignumber.js' -import { useSiascanExchangeRate } from './useExchangeRate' type Props = { sc: BigNumber @@ -12,7 +15,7 @@ export function useSiacoinFiat({ sc }: Props): { currency?: CurrencyOption } { const { settings } = useAppSettings() - const exchangeRate = useSiascanExchangeRate({ + const exchangeRate = useExchangeRate({ currency: settings.currency.id, }) const fiat = useMemo( diff --git a/libs/design-system/src/index.ts b/libs/design-system/src/index.ts index 472bf7de6..497723dc2 100644 --- a/libs/design-system/src/index.ts +++ b/libs/design-system/src/index.ts @@ -163,7 +163,6 @@ export * from './hooks/useServerFilters' export * from './hooks/useFormChanged' export * from './hooks/useDatasetEmptyState' export * from './hooks/useSiacoinFiat' -export * from './hooks/useExchangeRate' export * from './hooks/useOS' // data @@ -176,7 +175,6 @@ export * from './lib/clipboard' export * from './lib/image' export * from './lib/links' export * from './lib/utils' -export * from './lib/time' export * from './lib/numbers' export * from './lib/mnemonics' export * from './lib/contracts' diff --git a/libs/design-system/src/lib/chartData.ts b/libs/design-system/src/lib/chartData.ts index 6f9872f57..154cc0b05 100644 --- a/libs/design-system/src/lib/chartData.ts +++ b/libs/design-system/src/lib/chartData.ts @@ -1,11 +1,11 @@ -import { humanDate } from '@siafoundation/units' -import { omit } from '@technically/lodash' -import { ChartPoint } from '../components/ChartXY' import { + humanDate, daysInMilliseconds, hoursInMilliseconds, minutesInMilliseconds, -} from './time' +} from '@siafoundation/units' +import { omit } from '@technically/lodash' +import { ChartPoint } from '../components/ChartXY' type TransformMode = 'delta' | 'none' diff --git a/libs/design-system/src/lib/contracts.ts b/libs/design-system/src/lib/contracts.ts index 52813b545..aabba84d5 100644 --- a/libs/design-system/src/lib/contracts.ts +++ b/libs/design-system/src/lib/contracts.ts @@ -1,11 +1,11 @@ -import { daysToBlocks } from '@siafoundation/units' import { + daysToBlocks, daysInMilliseconds, monthsInMilliseconds, nowInMilliseconds, weeksInMilliseconds, yearsInMilliseconds, -} from './time' +} from '@siafoundation/units' export function getContractsTimeRangeBlockHeight( currentHeight: number, diff --git a/libs/react-core/package.json b/libs/react-core/package.json index f729ac38e..b2d0aef35 100644 --- a/libs/react-core/package.json +++ b/libs/react-core/package.json @@ -9,10 +9,12 @@ "dependencies": { "@siafoundation/next": "^0.1.3", "@siafoundation/request": "0.2.0", + "@siafoundation/units": "^3.1.1", "swr": "^2.1.1", "axios": "^0.27.2", "use-local-storage-state": "^18.3.3", - "detect-gpu": "^5.0.34" + "detect-gpu": "^5.0.34", + "bignumber.js": "^9.0.2" }, "types": "./src/index.d.ts" } diff --git a/libs/react-core/src/index.ts b/libs/react-core/src/index.ts index add2e93d8..abae5f095 100644 --- a/libs/react-core/src/index.ts +++ b/libs/react-core/src/index.ts @@ -9,6 +9,7 @@ export * from './useGetDownload' export * from './appSettings' export * from './appSettings/useExternalData/currency' export type { CurrencyDisplay } from './appSettings/useExternalData/types' +export * from './useExchangeRate' export * from './useTryUntil' export * from './userPrefersReducedMotion' export * from './mutate' diff --git a/libs/design-system/src/hooks/useExchangeRate.tsx b/libs/react-core/src/useExchangeRate.tsx similarity index 93% rename from libs/design-system/src/hooks/useExchangeRate.tsx rename to libs/react-core/src/useExchangeRate.tsx index ce238b626..3abc36a0a 100644 --- a/libs/design-system/src/hooks/useExchangeRate.tsx +++ b/libs/react-core/src/useExchangeRate.tsx @@ -1,12 +1,10 @@ -import { - CurrencyId, - useAppSettings, - useGetSwr, - RequestConfig, -} from '@siafoundation/react-core' import { useMemo } from 'react' import BigNumber from 'bignumber.js' -import { minutesInMilliseconds } from '../lib/time' +import { minutesInMilliseconds } from '@siafoundation/units' +import { CurrencyId } from './appSettings/useExternalData/currency' +import { RequestConfig } from './request' +import { useAppSettings } from './appSettings' +import { useGetSwr } from './useGet' const swrConfigDefaults = { revalidateOnFocus: false, diff --git a/libs/units/package.json b/libs/units/package.json index 7316ece25..2a42cb24f 100644 --- a/libs/units/package.json +++ b/libs/units/package.json @@ -4,7 +4,6 @@ "version": "3.1.1", "license": "MIT", "dependencies": { - "@siafoundation/react-core": "^1.3.0", "bignumber.js": "^9.0.2", "@technically/lodash": "^4.17.0", "blakejs": "^1.2.1", diff --git a/libs/units/src/index.ts b/libs/units/src/index.ts index 4e26d7f36..79068f0cd 100644 --- a/libs/units/src/index.ts +++ b/libs/units/src/index.ts @@ -2,6 +2,7 @@ export * from './storage' export * from './address' export * from './humanUnits' export * from './currency' +export * from './time' export * from './blockTime' export * from './blockHeight' export * from './bytes' diff --git a/libs/units/src/storage.ts b/libs/units/src/storage.ts index 1f4b1da8e..39db28250 100644 --- a/libs/units/src/storage.ts +++ b/libs/units/src/storage.ts @@ -4,7 +4,6 @@ import { SiaCentralHost } from '@siafoundation/sia-central-types' import BigNumber from 'bignumber.js' import { humanSiacoin, toSiacoins } from './currency' import { humanBytes, humanSpeed } from './humanUnits' -import { CurrencyOption } from '@siafoundation/react-core' import { valuePerTBPerMonthToPerBytePerBlock } from './valuePer' type Hastings = string @@ -12,7 +11,9 @@ type Hastings = string type Props = { price: Hastings exchange?: { - currency: CurrencyOption + currency: { + prefix: string + } rate: string } } diff --git a/libs/design-system/src/lib/time.ts b/libs/units/src/time.ts similarity index 100% rename from libs/design-system/src/lib/time.ts rename to libs/units/src/time.ts diff --git a/package-lock.json b/package-lock.json index 0a6202fd2..faeba6ec3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -287,7 +287,6 @@ "@siafoundation/next": "^0.1.3", "@siafoundation/react-core": "^1.3.0", "@siafoundation/react-icons": "^0.2.3", - "@siafoundation/sia-central-react": "^3.1.1", "@siafoundation/types": "^0.6.0", "@siafoundation/units": "^3.1.1", "@tailwindcss/container-queries": "^0.1.1", @@ -475,7 +474,9 @@ "dependencies": { "@siafoundation/next": "^0.1.3", "@siafoundation/request": "0.2.0", + "@siafoundation/units": "^3.1.1", "axios": "^0.27.2", + "bignumber.js": "^9.0.2", "detect-gpu": "^5.0.34", "swr": "^2.1.1", "use-local-storage-state": "^18.3.3" @@ -680,7 +681,6 @@ "version": "3.1.1", "license": "MIT", "dependencies": { - "@siafoundation/react-core": "^1.3.0", "@siafoundation/sia-central-types": "0.1.1", "@siafoundation/types": "0.6.0", "@technically/lodash": "^4.17.0", @@ -33839,7 +33839,6 @@ "@siafoundation/next": "^0.1.3", "@siafoundation/react-core": "^1.3.0", "@siafoundation/react-icons": "^0.2.3", - "@siafoundation/sia-central-react": "^3.1.1", "@siafoundation/types": "^0.6.0", "@siafoundation/units": "^3.1.1", "@tailwindcss/container-queries": "^0.1.1", @@ -33943,7 +33942,9 @@ "requires": { "@siafoundation/next": "^0.1.3", "@siafoundation/request": "0.2.0", + "@siafoundation/units": "^3.1.1", "axios": "^0.27.2", + "bignumber.js": "^9.0.2", "detect-gpu": "^5.0.34", "swr": "^2.1.1", "use-local-storage-state": "^18.3.3" @@ -34024,7 +34025,6 @@ "@siafoundation/units": { "version": "file:libs/units", "requires": { - "@siafoundation/react-core": "^1.3.0", "@siafoundation/sia-central-types": "0.1.1", "@siafoundation/types": "0.6.0", "@technically/lodash": "^4.17.0",