Skip to content

Commit

Permalink
refactor: consolidate units, deprecate packages
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Dec 8, 2023
1 parent db5d692 commit 77e484d
Show file tree
Hide file tree
Showing 150 changed files with 296 additions and 84,394 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ The Sia web libraries provide developers with convenient TypeScript SDKs for usi
- [@siafoundation/react-walletd](libs/react-walletd) - React hooks for interacting with `walletd`.
- [@siafoundation/react-sia-central](libs/react-sia-central) - React hooks for interacting with the Sia Central API.
- [@siafoundation/sia-central](libs/sia-central) - Methods and types for interacting with the Sia Central API.
- [@siafoundation/sia-js](libs/sia-js) - Core Sia types and library methods for v1 `siad`.
- [@siafoundation/sia-nodejs](libs/sia-nodejs) - Sia NodeJS client for controlling a v1 `siad`.
- [@siafoundation/design-system](libs/design-system) - React-based design system used across Sia apps and websites.
- [@siafoundation/data-sources](libs/data-sources) - Data sources used for stats on the website.
- [@siafoundation/fonts](libs/fonts) - Next font configuration for use across apps.
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/app/address/[id]/opengraph-image.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getSiaCentralAddress } from '@siafoundation/sia-central'
import { humanSiacoin, humanSiafund } from '@siafoundation/sia-js'
import { humanSiacoin, humanSiafund } from '@siafoundation/units'
import { getOGImage } from '../../../components/OGImageEntity'
import { siaCentralApi } from '../../../config'
import { truncate } from '@siafoundation/design-system'
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/app/block/[id]/opengraph-image.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getSiaCentralBlock } from '@siafoundation/sia-central'
import { humanDate } from '@siafoundation/sia-js'
import { humanDate } from '@siafoundation/units'
import { getOGImage } from '../../../components/OGImageEntity'
import { siaCentralApi } from '../../../config'
import { truncate } from '@siafoundation/design-system'
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/app/contract/[id]/opengraph-image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
getSiaCentralContract,
getSiaCentralExchangeRates,
} from '@siafoundation/sia-central'
import { humanBytes, humanDate } from '@siafoundation/sia-js'
import { humanBytes, humanDate } from '@siafoundation/units'
import { getOGImage } from '../../../components/OGImageEntity'
import { siaCentralApi } from '../../../config'
import { truncate } from '@siafoundation/design-system'
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/app/host/[id]/opengraph-image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
getStorageCost,
getUploadCost,
getUploadSpeed,
humanBytes,
} from '@siafoundation/units'
import { humanBytes } from '@siafoundation/sia-js'
import { truncate } from '@siafoundation/design-system'
import { CurrencyOption, currencyOptions } from '@siafoundation/react-core'

Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/app/opengraph-image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
} from '@siafoundation/sia-central'
import { getOGImage } from '../components/OGImage'
import { network, siaCentralApi } from '../config'
import { humanBytes } from '@siafoundation/sia-js'
import { humanBytes } from '@siafoundation/units'
import { PreviewValue } from '../components/OGImage/Preview'

export const revalidate = 0
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
getSiaCentralHostsNetworkMetrics,
} from '@siafoundation/sia-central'
import { buildMetadata } from '../lib/utils'
import { humanBytes } from '@siafoundation/sia-js'
import { humanBytes } from '@siafoundation/units'
import { getLastFewBlocks } from '../lib/blocks'

export function generateMetadata(): Metadata {
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/app/tx/[id]/opengraph-image.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getSiaCentralTransaction } from '@siafoundation/sia-central'
import { humanDate } from '@siafoundation/sia-js'
import { humanDate } from '@siafoundation/units'
import { getOGImage } from '../../../components/OGImageEntity'
import { siaCentralApi } from '../../../config'
import { truncate } from '@siafoundation/design-system'
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/components/Address/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
EntityList,
EntityListItemProps,
} from '@siafoundation/design-system'
import { humanNumber } from '@siafoundation/sia-js'
import { humanNumber } from '@siafoundation/units'
import { ExplorerDatum, DatumProps } from '../ExplorerDatum'
import { useMemo, useState } from 'react'
import { routes } from '../../config/routes'
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/components/Block/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Badge, Tooltip, EntityList } from '@siafoundation/design-system'
import { humanNumber } from '@siafoundation/sia-js'
import { humanNumber } from '@siafoundation/units'
import { ExplorerDatum, DatumProps } from '../ExplorerDatum'
import { useMemo } from 'react'
import { routes } from '../../config/routes'
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/components/Contract/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
SiaCentralContract,
SiaCentralExchangeRates,
} from '@siafoundation/sia-central'
import { humanBytes, humanDate, humanSiacoin } from '@siafoundation/sia-js'
import { humanBytes, humanDate, humanSiacoin } from '@siafoundation/units'
import { EntityList, EntityListItemProps } from '@siafoundation/design-system'
import { DatumProps, ExplorerDatum } from '../ExplorerDatum'
import { ContentLayout } from '../ContentLayout'
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/components/Faucet/FaucetFundForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
Paragraph,
triggerToast,
} from '@siafoundation/design-system'
import { toHastings } from '@siafoundation/sia-js'
import { toHastings } from '@siafoundation/units'
import BigNumber from 'bignumber.js'
import { useFormik } from 'formik'
import * as Yup from 'yup'
Expand Down
3 changes: 2 additions & 1 deletion apps/explorer/components/Home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
Tooltip,
EntityList,
} from '@siafoundation/design-system'
import { humanBytes, humanNumber } from '@siafoundation/sia-js'
import { useMemo } from 'react'
import { routes } from '../../config/routes'
import { ContentLayout } from '../ContentLayout'
Expand All @@ -19,6 +18,8 @@ import {
} from '@siafoundation/sia-central'
import { hashToAvatar } from '../../lib/avatar'
import {
humanBytes,
humanNumber,
getDownloadCost,
getStorageCost,
getUploadCost,
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/components/Host/HostInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
WarningFilled16,
} from '@siafoundation/react-icons'
import { SiaCentralHost } from '@siafoundation/sia-central'
import { humanDate } from '@siafoundation/sia-js'
import { humanDate } from '@siafoundation/units'
import { formatDistance } from 'date-fns'

type Props = {
Expand Down
11 changes: 5 additions & 6 deletions apps/explorer/components/Host/HostSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ import {
SiaCentralHost,
} from '@siafoundation/sia-central'
import { DatumProps, ExplorerDatum } from '../ExplorerDatum'
import { Panel, toFixedOrPrecision } from '@siafoundation/design-system'
import BigNumber from 'bignumber.js'
import {
Panel,
blocksToDays,
blocksToMonths,
toFixedOrPrecision,
} from '@siafoundation/design-system'
import BigNumber from 'bignumber.js'
import { humanBytes, humanSiacoin, toSiacoins } from '@siafoundation/sia-js'
import {
humanBytes,
humanSiacoin,
toSiacoins,
getDownloadCost,
getStorageCost,
getUploadCost,
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/components/Transaction/TransactionHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Badge, Text, Tooltip } from '@siafoundation/design-system'
import { SiaCentralTransaction } from '@siafoundation/sia-central'
import { humanDate } from '@siafoundation/sia-js'
import { humanDate } from '@siafoundation/units'
import { routes } from '../../config/routes'
import { EntityHeading } from '../EntityHeading'

Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/lib/currency.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { toFixedOrPrecision } from '@siafoundation/design-system'
import { CurrencyOption } from '@siafoundation/react-core'
import { humanSiacoin } from '@siafoundation/sia-js';
import { humanSiacoin } from '@siafoundation/units'
import BigNumber from 'bignumber.js'

const digits = 2
Expand Down
2 changes: 1 addition & 1 deletion apps/hostd/components/Config/AnnounceButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import { Bullhorn16 } from '@siafoundation/react-icons'
import { useDialog } from '../../contexts/dialog'
import { useSettingsAnnounce, useTxPoolFee } from '@siafoundation/react-hostd'
import { humanSiacoin } from '@siafoundation/sia-js'
import { humanSiacoin } from '@siafoundation/units'
import { useCallback } from 'react'
import BigNumber from 'bignumber.js'

Expand Down
2 changes: 1 addition & 1 deletion apps/hostd/components/Home/HomeBandwidth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
DatumCardConfigurable,
DatumScrollArea,
} from '@siafoundation/design-system'
import { humanBytes } from '@siafoundation/sia-js'
import { humanBytes } from '@siafoundation/units'
import { useMetrics } from '../../contexts/metrics'

export function HomeBandwidth() {
Expand Down
2 changes: 1 addition & 1 deletion apps/hostd/components/Home/HomeOperations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
DatumCardConfigurable,
DatumScrollArea,
} from '@siafoundation/design-system'
import { humanNumber } from '@siafoundation/sia-js'
import { humanNumber } from '@siafoundation/units'
import { useMetrics } from '../../contexts/metrics'

export function HomeOperations() {
Expand Down
2 changes: 1 addition & 1 deletion apps/hostd/components/Home/HomeStorage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
DatumCardConfigurable,
DatumScrollArea,
} from '@siafoundation/design-system'
import { humanBytes } from '@siafoundation/sia-js'
import { humanBytes } from '@siafoundation/units'
import { useMetrics } from '../../contexts/metrics'

export function HomeStorage() {
Expand Down
2 changes: 1 addition & 1 deletion apps/hostd/components/Home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { useDialog } from '../../contexts/dialog'
import { DataTimeSpan, dataTimeSpanOptions } from '../../contexts/metrics/types'
import { HomeOperations } from './HomeOperations'
import { HomeBandwidth } from './HomeBandwidth'
import { humanDate } from '@siafoundation/sia-js'
import { humanDate } from '@siafoundation/units'
import { HomeCollateral } from './HomeCollateral'

export function Home() {
Expand Down
2 changes: 1 addition & 1 deletion apps/hostd/components/Node/Logs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
useDatasetEmptyState,
} from '@siafoundation/design-system'
import { useLogsSearch } from '@siafoundation/react-hostd'
import { humanDate } from '@siafoundation/sia-js'
import { humanDate } from '@siafoundation/units'
import { cx } from 'class-variance-authority'
import { times } from 'lodash'

Expand Down
2 changes: 1 addition & 1 deletion apps/hostd/components/OnboardingBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { routes } from '../config/routes'
import { useDialog } from '../contexts/dialog'
import { useSettings, useWallet } from '@siafoundation/react-hostd'
import BigNumber from 'bignumber.js'
import { toHastings } from '@siafoundation/sia-js'
import { toHastings } from '@siafoundation/units'
import { useAppSettings } from '@siafoundation/react-core'
import { useVolumes } from '../contexts/volumes'
import useLocalStorageState from 'use-local-storage-state'
Expand Down
2 changes: 1 addition & 1 deletion apps/hostd/components/Volumes/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Button, Table, Text, Separator } from '@siafoundation/design-system'
import { Add20 } from '@siafoundation/react-icons'
import { humanBytes } from '@siafoundation/sia-js'
import { humanBytes } from '@siafoundation/units'
import { HostdAuthedLayout } from '../HostdAuthedLayout'
import { useDialog } from '../../contexts/dialog'
import { HostdSidenav } from '../HostdSidenav'
Expand Down
3 changes: 2 additions & 1 deletion apps/hostd/contexts/config/fields.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { blocksToMonths, ConfigFields } from '@siafoundation/design-system'
import { blocksToMonths } from '@siafoundation/units'
import { ConfigFields } from '@siafoundation/design-system'
import BigNumber from 'bignumber.js'
import { dnsProviderOptions, initialValues, scDecimalPlaces } from './types'
import { SiaCentralExchangeRates } from '@siafoundation/sia-central'
Expand Down
13 changes: 7 additions & 6 deletions apps/hostd/contexts/config/transform.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import {
bytesToMB,
MBToBytes,
monthsToBlocks,
} from '@siafoundation/design-system'
import {
DNSAWSOptions,
DNSCloudflareOptions,
DNSDuckDNSOptions,
DNSNoIPOptions,
HostSettings,
} from '@siafoundation/react-hostd'
import { toHastings, toSiacoins } from '@siafoundation/sia-js'
import {
bytesToMB,
MBToBytes,
monthsToBlocks,
toHastings,
toSiacoins,
} from '@siafoundation/units'
import {
humanBaseRpcPrice,
humanEgressPrice,
Expand Down
3 changes: 1 addition & 2 deletions apps/hostd/contexts/contracts/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
Badge,
ContractTimeline,
ValueNum,
blockHeightToTime,
ValueScFiat,
} from '@siafoundation/design-system'
import {
Expand All @@ -16,7 +15,7 @@ import {
Money16,
} from '@siafoundation/react-icons'
import { ContractStatus } from '@siafoundation/react-hostd'
import { humanBytes, humanDate } from '@siafoundation/sia-js'
import { blockHeightToTime, humanBytes, humanDate } from '@siafoundation/units'
import { ContractContextMenu } from '../../components/Contracts/ContractContextMenu'
import { ContractData, TableColumnId } from './types'

Expand Down
8 changes: 6 additions & 2 deletions apps/hostd/contexts/metrics/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ import {
formatChartData,
getDataIntervalLabelFormatter,
getTimeRange,
MiBToBytes,
minutesInMilliseconds,
ValueScFiat,
} from '@siafoundation/design-system'
import { humanBytes, humanNumber, humanSiacoin } from '@siafoundation/sia-js'
import {
MiBToBytes,
humanBytes,
humanNumber,
humanSiacoin,
} from '@siafoundation/units'
import { useCallback, useMemo } from 'react'
import { chartConfigs } from '../../config/charts'
import { useMetricsPeriod } from '@siafoundation/react-hostd'
Expand Down
2 changes: 1 addition & 1 deletion apps/hostd/contexts/volumes/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
WarningSquareFilled16,
InProgress16,
} from '@siafoundation/react-icons'
import { humanBytes } from '@siafoundation/sia-js'
import { humanBytes } from '@siafoundation/units'
import { VolumeContextMenu } from '../../components/Volumes/VolumeContextMenu'
import { VolumeData, TableColumnId } from './types'

Expand Down
2 changes: 1 addition & 1 deletion apps/hostd/contexts/volumes/dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useMemo } from 'react'
import { useVolumes, VolumeMeta } from '@siafoundation/react-hostd'
import { VolumeData } from './types'
import BigNumber from 'bignumber.js'
import { MiBToBytes } from '@siafoundation/design-system'
import { MiBToBytes } from '@siafoundation/units'

export function useDataset({
response,
Expand Down
2 changes: 1 addition & 1 deletion apps/hostd/dialogs/AlertsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
useAlerts,
useAlertsDismiss,
} from '@siafoundation/react-hostd'
import { humanTime } from '@siafoundation/sia-js'
import { humanTime } from '@siafoundation/units'
import { useCallback } from 'react'

type Props = {
Expand Down
4 changes: 1 addition & 3 deletions apps/hostd/dialogs/VolumeCreateDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {
Paragraph,
Dialog,
bytesToGB,
GBToBytes,
GBToSectors,
triggerErrorToast,
triggerSuccessToast,
Expand All @@ -13,7 +11,7 @@ import {
useOnInvalid,
} from '@siafoundation/design-system'
import { useSystemDirectory, useVolumeCreate } from '@siafoundation/react-hostd'
import { humanBytes } from '@siafoundation/sia-js'
import { bytesToGB, GBToBytes, humanBytes } from '@siafoundation/units'
import BigNumber from 'bignumber.js'
import { useCallback, useEffect, useMemo } from 'react'
import { useForm } from 'react-hook-form'
Expand Down
2 changes: 1 addition & 1 deletion apps/hostd/dialogs/VolumeDeleteDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
FieldText,
} from '@siafoundation/design-system'
import { useVolume, useVolumeDelete } from '@siafoundation/react-hostd'
import { humanBytes } from '@siafoundation/sia-js'
import { humanBytes } from '@siafoundation/units'
import { useCallback, useMemo } from 'react'
import { useForm } from 'react-hook-form'
import { useDialog } from '../contexts/dialog'
Expand Down
4 changes: 1 addition & 3 deletions apps/hostd/dialogs/VolumeResizeDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import {
Text,
Dialog,
Code,
bytesToGB,
GBToBytes,
sectorsToGB,
Label,
GBToSectors,
Expand All @@ -20,7 +18,7 @@ import {
useVolume,
useVolumeResize,
} from '@siafoundation/react-hostd'
import { humanBytes } from '@siafoundation/sia-js'
import { bytesToGB, GBToBytes, humanBytes } from '@siafoundation/units'
import BigNumber from 'bignumber.js'
import { useCallback, useEffect, useMemo } from 'react'
import { useForm } from 'react-hook-form'
Expand Down
4 changes: 2 additions & 2 deletions apps/hostd/dialogs/VolumeSizeDiff.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GBToBytes, Text } from '@siafoundation/design-system'
import { humanBytes } from '@siafoundation/sia-js'
import { Text } from '@siafoundation/design-system'
import { GBToBytes, humanBytes } from '@siafoundation/units'
import { cx } from 'class-variance-authority'

type Props = {
Expand Down
2 changes: 1 addition & 1 deletion apps/hostd/hooks/useHostOSPathSeparator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export function useHostOSPathSeparator() {
},
},
})
return state.data?.OS === 'windows' ? '\\' : '/'
return state.data?.os === 'windows' ? '\\' : '/'
}
2 changes: 1 addition & 1 deletion apps/hostd/lib/humanUnits.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { monthsToBlocks, TBToBytes } from '@siafoundation/design-system'
import { monthsToBlocks, TBToBytes } from '@siafoundation/units'
import BigNumber from 'bignumber.js'

export const humanStoragePriceSuffix = '/TB/month'
Expand Down
Loading

0 comments on commit 77e484d

Please sign in to comment.