Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: split out sia-central-types #579

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/mean-singers-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@siafoundation/sia-central-js': minor
---

sia-central is now named sia-central-js.
5 changes: 5 additions & 0 deletions .changeset/real-needles-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@siafoundation/sia-central-types': minor
---

Introduced new library for sia central types.
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,4 +1,4 @@
import { getSiaCentralAddress } from '@siafoundation/sia-central'
import { getSiaCentralAddress } from '@siafoundation/sia-central-js'
import { humanSiacoin, humanSiafund } from '@siafoundation/units'
import { getOGImage } from '../../../components/OGImageEntity'
import { siaCentralApi } from '../../../config'
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/app/address/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getSiaCentralAddress } from '@siafoundation/sia-central'
import { getSiaCentralAddress } from '@siafoundation/sia-central-js'
import { Address } from '../../../components/Address'
import { Metadata } from 'next'
import { routes } from '../../../config/routes'
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,4 +1,4 @@
import { getSiaCentralBlock } from '@siafoundation/sia-central'
import { getSiaCentralBlock } from '@siafoundation/sia-central-js'
import { humanDate } from '@siafoundation/units'
import { getOGImage } from '../../../components/OGImageEntity'
import { siaCentralApi } from '../../../config'
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/app/block/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getTitleId } from '@siafoundation/design-system'
import { Block } from '../../../components/Block'
import { routes } from '../../../config/routes'
import { Metadata } from 'next'
import { getSiaCentralBlock } from '@siafoundation/sia-central'
import { getSiaCentralBlock } from '@siafoundation/sia-central-js'
import { buildMetadata } from '../../../lib/utils'
import { siaCentralApi } from '../../../config'
import { notFound } from 'next/navigation'
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
@@ -1,7 +1,7 @@
import {
getSiaCentralContract,
getSiaCentralExchangeRates,
} from '@siafoundation/sia-central'
} from '@siafoundation/sia-central-js'
import { humanBytes, humanDate } from '@siafoundation/units'
import { getOGImage } from '../../../components/OGImageEntity'
import { siaCentralApi } from '../../../config'
Expand Down
4 changes: 2 additions & 2 deletions apps/explorer/app/contract/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { SiaCentralContract } from '@siafoundation/sia-central-types'
import {
SiaCentralContract,
getSiaCentralContract,
getSiaCentralExchangeRates,
getSiaCentralTransaction,
} from '@siafoundation/sia-central'
} from '@siafoundation/sia-central-js'
import { ContractView } from '../../../components/ContractView'
import { Metadata } from 'next'
import { routes } from '../../../config/routes'
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
@@ -1,7 +1,7 @@
import {
getSiaCentralExchangeRates,
getSiaCentralHost,
} from '@siafoundation/sia-central'
} from '@siafoundation/sia-central-js'
import { getOGImage } from '../../../components/OGImageEntity'
import { siaCentralApi } from '../../../config'
import {
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/app/host/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
getSiaCentralExchangeRates,
getSiaCentralHost,
} from '@siafoundation/sia-central'
} from '@siafoundation/sia-central-js'
import { Metadata } from 'next'
import { routes } from '../../../config/routes'
import { buildMetadata } from '../../../lib/utils'
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/app/opengraph-image.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
getSiaCentralBlockLatest,
getSiaCentralHostsNetworkMetrics,
} from '@siafoundation/sia-central'
} from '@siafoundation/sia-central-js'
import { getOGImage } from '../components/OGImage'
import { network, siaCentralApi } from '../config'
import { humanBytes } from '@siafoundation/units'
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 @@ -6,7 +6,7 @@ import {
getSiaCentralExchangeRates,
getSiaCentralHosts,
getSiaCentralHostsNetworkMetrics,
} from '@siafoundation/sia-central'
} from '@siafoundation/sia-central-js'
import { buildMetadata } from '../lib/utils'
import { humanBytes } from '@siafoundation/units'
import { getLastFewBlocks } from '../lib/blocks'
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,4 +1,4 @@
import { getSiaCentralTransaction } from '@siafoundation/sia-central'
import { getSiaCentralTransaction } from '@siafoundation/sia-central-js'
import { humanDate } from '@siafoundation/units'
import { getOGImage } from '../../../components/OGImageEntity'
import { siaCentralApi } from '../../../config'
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/app/tx/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Metadata } from 'next'
import { routes } from '../../../config/routes'
import { Transaction } from '../../../components/Transaction'
import { getSiaCentralTransaction } from '@siafoundation/sia-central'
import { getSiaCentralTransaction } from '@siafoundation/sia-central-js'
import { buildMetadata } from '../../../lib/utils'
import { siaCentralApi } from '../../../config'
import { notFound } from 'next/navigation'
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 @@ -17,7 +17,7 @@ import { routes } from '../../config/routes'
import { EntityHeading } from '../EntityHeading'
import BigNumber from 'bignumber.js'
import { ContentLayout } from '../ContentLayout'
import { SiaCentralAddressResponse } from '@siafoundation/sia-central'
import { SiaCentralAddressResponse } from '@siafoundation/sia-central-types'

type Tab = 'transactions' | 'evolution' | 'utxos'

Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/components/Block/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useMemo } from 'react'
import { routes } from '../../config/routes'
import { EntityHeading } from '../EntityHeading'
import { ContentLayout } from '../ContentLayout'
import { SiaCentralBlock } from '@siafoundation/sia-central'
import { SiaCentralBlock } from '@siafoundation/sia-central-types'

type Props = {
block: SiaCentralBlock
Expand Down
6 changes: 2 additions & 4 deletions apps/explorer/components/Contract/ContractHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import {
LinkButton,
} from '@siafoundation/design-system'
import { ArrowLeft16, ArrowRight16 } from '@siafoundation/react-icons'
import {
SiaCentralContract,
getSiaCentralBlockLatest,
} from '@siafoundation/sia-central'
import { SiaCentralContract } from '@siafoundation/sia-central-types'
import { getSiaCentralBlockLatest } from '@siafoundation/sia-central-js'
import { lowerCase } from '@technically/lodash'
import { routes } from '../../config/routes'
import { EntityHeading } from '../EntityHeading'
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,
SiaCentralPartialSiacoinOutput,
} from '@siafoundation/sia-central'
} from '@siafoundation/sia-central-types'
import { humanBytes, humanDate, humanSiacoin } from '@siafoundation/units'
import { EntityList, EntityListItemProps } from '@siafoundation/design-system'
import { DatumProps, ExplorerDatum } from '../ExplorerDatum'
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/components/ContractView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
SiaCentralContract,
SiaCentralExchangeRates,
SiaCentralTransaction,
} from '@siafoundation/sia-central'
} from '@siafoundation/sia-central-types'
import { Contract } from '../Contract'

type Props = {
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/components/Home/HostListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
CloudUpload16,
VmdkDisk16,
} from '@siafoundation/react-icons'
import { SiaCentralExchangeRates } from '@siafoundation/sia-central'
import { SiaCentralExchangeRates } from '@siafoundation/sia-central-types'
import {
getDownloadCost,
getDownloadSpeed,
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/components/Home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
SiaCentralExchangeRates,
SiaCentralHost,
SiaCentralHostsNetworkMetricsResponse,
} from '@siafoundation/sia-central'
} from '@siafoundation/sia-central-types'
import { hashToAvatar } from '../../lib/avatar'
import {
humanBytes,
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/components/Host/HostHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Avatar } from '@siafoundation/design-system'
import {
SiaCentralExchangeRates,
SiaCentralHost,
} from '@siafoundation/sia-central'
} from '@siafoundation/sia-central-types'
import { hashToAvatar } from '../../lib/avatar'
import { HostPricing } from './HostPricing'
import { HostInfo } from './HostInfo'
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 @@ -11,7 +11,7 @@ import {
Time16,
WarningFilled16,
} from '@siafoundation/react-icons'
import { SiaCentralHost } from '@siafoundation/sia-central'
import { SiaCentralHost } from '@siafoundation/sia-central-types'
import { humanDate } from '@siafoundation/units'
import { formatDistance } from 'date-fns'

Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/components/Host/HostPricing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
CloudUpload16,
VmdkDisk16,
} from '@siafoundation/react-icons'
import { SiaCentralExchangeRates } from '@siafoundation/sia-central'
import { SiaCentralExchangeRates } from '@siafoundation/sia-central-types'
import { useMemo } from 'react'
import {
getDownloadCost,
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/components/Host/HostSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client'

import { useMemo } from 'react'
import { SiaCentralExchangeRates } from '@siafoundation/sia-central'
import { SiaCentralExchangeRates } from '@siafoundation/sia-central-types'
import { DatumProps, ExplorerDatum } from '../ExplorerDatum'
import { Panel, toFixedOrPrecision } from '@siafoundation/design-system'
import BigNumber from 'bignumber.js'
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/components/Host/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
SiaCentralExchangeRates,
SiaCentralHost,
} from '@siafoundation/sia-central'
} from '@siafoundation/sia-central-types'
import { ContentLayout } from '../ContentLayout'
import { HostHeader } from './HostHeader'
import { HostSettings } from './HostSettings'
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/components/Host/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import {
SiaCentralHost,
SiaCentralHostSettings,
} from '@siafoundation/sia-central'
} from '@siafoundation/sia-central-types'

export type SiaCentralHostScanned = SiaCentralHost & {
settings: SiaCentralHostSettings
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,5 +1,5 @@
import { Badge, Text, Tooltip } from '@siafoundation/design-system'
import { SiaCentralTransaction } from '@siafoundation/sia-central'
import { SiaCentralTransaction } from '@siafoundation/sia-central-types'
import { humanDate } from '@siafoundation/units'
import { routes } from '../../config/routes'
import { EntityHeading } from '../EntityHeading'
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/components/Transaction/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { useMemo } from 'react'
import BigNumber from 'bignumber.js'
import { SiaCentralTransaction } from '@siafoundation/sia-central'
import { SiaCentralTransaction } from '@siafoundation/sia-central-types'
import { EntityList, EntityListItemProps } from '@siafoundation/design-system'
import { routes } from '../../config/routes'
import { ContentLayout } from '../ContentLayout'
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/hooks/useExchangeRate.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client'

import { useAppSettings } from '@siafoundation/react-core'
import { SiaCentralExchangeRates } from '@siafoundation/sia-central'
import { SiaCentralExchangeRates } from '@siafoundation/sia-central-types'

export function useExchangeRate(rates?: SiaCentralExchangeRates) {
const {
Expand Down
4 changes: 2 additions & 2 deletions apps/explorer/lib/blocks.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { siaCentralApi } from '../config'
import { SiaCentralBlock } from '@siafoundation/sia-central-types'
import {
SiaCentralBlock,
getSiaCentralBlock,
getSiaCentralBlocks,
} from '@siafoundation/sia-central'
} from '@siafoundation/sia-central-js'
import { range } from '@technically/lodash'

export async function getLastFewBlocksOneByOne(block?: SiaCentralBlock) {
Expand Down
2 changes: 1 addition & 1 deletion apps/hostd/contexts/config/fields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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'
import { SiaCentralExchangeRates } from '@siafoundation/sia-central-types'
import { calculateMaxCollateral } from './transform'

type Categories = 'host' | 'pricing' | 'DNS' | 'bandwidth' | 'RHP3'
Expand Down
2 changes: 1 addition & 1 deletion apps/renterd/components/Hosts/HostMap/HostItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '@siafoundation/design-system'
import { cx } from 'class-variance-authority'
import BigNumber from 'bignumber.js'
import { SiaCentralHost } from '@siafoundation/sia-central'
import { SiaCentralHost } from '@siafoundation/sia-central-types'
import {
monthsToBlocks,
TBToBytes,
Expand Down
2 changes: 1 addition & 1 deletion apps/renterd/contexts/config/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
RedundancySettings,
UploadPackingSettings,
} from '@siafoundation/renterd-types'
import { SiaCentralHostsNetworkAveragesResponse } from '@siafoundation/sia-central'
import { SiaCentralHostsNetworkAveragesResponse } from '@siafoundation/sia-central-types'
import BigNumber from 'bignumber.js'
import { TBToBytes } from '@siafoundation/units'

Expand Down
2 changes: 1 addition & 1 deletion apps/renterd/contexts/hosts/dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from '@siafoundation/renterd-react'
import { ContractData } from '../contracts/types'
import { useApp } from '../app'
import { SiaCentralHost } from '@siafoundation/sia-central'
import { SiaCentralHost } from '@siafoundation/sia-central-types'

export function useDataset({
autopilotStatus,
Expand Down
2 changes: 1 addition & 1 deletion apps/website/content/exchangeRates.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getSiaCentralExchangeRates } from '@siafoundation/sia-central'
import { getSiaCentralExchangeRates } from '@siafoundation/sia-central-js'
import { getCacheValue } from '../lib/cache'
import { getMinutesInSeconds } from '../lib/time'

Expand Down
3 changes: 2 additions & 1 deletion apps/website/content/geoHosts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { SiaCentralHost, getSiaCentralHosts } from '@siafoundation/sia-central'
import { SiaCentralHost } from '@siafoundation/sia-central-types'
import { getSiaCentralHosts } from '@siafoundation/sia-central-js'
import { getCacheValue } from '../lib/cache'
import { getMinutesInSeconds } from '../lib/time'

Expand Down
2 changes: 1 addition & 1 deletion apps/website/content/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getMinutesInSeconds } from '../lib/time'
import {
getSiaCentralBlockLatest,
getSiaCentralHostsNetworkMetrics,
} from '@siafoundation/sia-central'
} from '@siafoundation/sia-central-js'

const maxAge = getMinutesInSeconds(5)

Expand Down
2 changes: 1 addition & 1 deletion libs/design-system/src/core/SiacoinField.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { SiacoinField } from './SiacoinField'
import { fireEvent, render, waitFor, act } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { useState } from 'react'
import { SiaCentralExchangeRatesResponse } from '@siafoundation/sia-central'
import { SiaCentralExchangeRatesResponse } from '@siafoundation/sia-central-types'
import { setupServer } from 'msw/node'
import { HttpResponse, http } from 'msw'

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"@nx/dependency-checks": [
"error",
{
"ignoredFiles": ["libs/sia-central/rollup.config.js"]
"ignoredFiles": ["libs/sia-central-js/rollup.config.js"]
}
]
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @siafoundation/sia-central
# @siafoundation/sia-central-js

## 0.3.3

Expand Down
7 changes: 7 additions & 0 deletions libs/sia-central-js/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# sia-central-js

Methods and types for interacting with the Sia Central API.

## Running unit tests

Run `nx test sia-central-js` to execute the unit tests via [Jest](https://jestjs.io).
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable */
export default {
displayName: 'sia-central',
displayName: 'sia-central-js',
preset: '../../jest.preset.js',
transform: {
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',
Expand All @@ -13,5 +13,5 @@ export default {
],
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/libs/sia-central',
coverageDirectory: '../../coverage/libs/sia-central-js',
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "@siafoundation/sia-central",
"name": "@siafoundation/sia-central-js",
"description": "Methods and types for interacting with the Sia Central API.",
"version": "0.3.3",
"license": "MIT",
"dependencies": {
"@technically/lodash": "^4.17.0"
"@technically/lodash": "^4.17.0",
"@siafoundation/sia-central-types": "0.0.0"
},
"types": "./src/index.d.ts"
}
Loading
Loading