Skip to content

Commit

Permalink
refactor: move off sia central
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Feb 28, 2025
1 parent 2d83b41 commit a03cce0
Show file tree
Hide file tree
Showing 77 changed files with 1,141 additions and 615 deletions.
2 changes: 0 additions & 2 deletions .changeset/ten-geckos-rest.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
---
'@siafoundation/e2e': minor
'@siafoundation/sia-central-mock': minor
'@siafoundation/walletd-mock': minor
---

Upgraded playwright dependencies.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ The Sia web libraries provide developers with convenient TypeScript SDKs for usi
- [@siafoundation/explored-react](libs/explored-react) - React hooks for interacting with `explored`.
- [@siafoundation/explored-types](libs/explored-types) - Types for `explored`.
- [@siafoundation/design-system](libs/design-system) - React-based design system used across Sia apps and websites.
- [@siafoundation/sia-central-types](libs/sia-central-types) - Types for the Sia Central API.
- [@siafoundation/sia-central-js](libs/sia-central-js) - SDK for interacting with the Sia Central API.
- [@siafoundation/sia-central-react](libs/sia-central-react) - React hooks for interacting with the Sia Central API.
- [@siafoundation/units](libs/units) - Methods and types for converting and displaying units.
- [@siafoundation/types](libs/types) - Core Sia types and library methods.
- [@siafoundation/react-core](libs/react-core) - Core library for building React hooks for interacting with a Sia daemon.
Expand Down Expand Up @@ -73,8 +70,6 @@ The Sia web libraries provide developers with convenient TypeScript SDKs for usi
- [explorer-e2e](apps/explorer-e2e) - App for testing explorer.
- [e2e](libs/e2e) - Shared e2e testing code.
- [@siafoundation/clusterd](libs/clusterd) - Methods for controlling `clusterd` in e2e testing.
- [@siafoundation/walletd-mock](libs/walletd-mock) - `walletd` data and API mock library for testing.
- [@siafoundation/sia-central-mock](libs/sia-central-mock) - Sia Central data and API mock library for testing.

## Development

Expand Down
7 changes: 5 additions & 2 deletions apps/explorer/components/Contract/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import { useMemo } from 'react'
import BigNumber from 'bignumber.js'
import { humanBytes, humanSiacoin } from '@siafoundation/units'
import { EntityList, EntityListItemProps } from '@siafoundation/design-system'
import {
EntityList,
EntityListItemProps,
useActiveCurrencySiascanExchangeRate,
} from '@siafoundation/design-system'
import { DatumProps, ExplorerDatum } from '../ExplorerDatum'
import { ContentLayout } from '../ContentLayout'
import { ContractHeader } from './ContractHeader'
Expand All @@ -14,7 +18,6 @@ import {
SiacoinOutput,
} from '@siafoundation/explored-types'
import { blockHeightToHumanDate } from '../../lib/time'
import { useActiveCurrencySiascanExchangeRate } from '@siafoundation/react-core'
import { siacoinToFiat } from '../../lib/currency'
import LoadingCurrency from '../LoadingCurrency'
import LoadingTimestamp from '../LoadingTimestamp'
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 @@ -5,6 +5,7 @@ import {
BlockList,
Tooltip,
EntityList,
useActiveCurrencySiascanExchangeRate,
} from '@siafoundation/design-system'
import { useMemo } from 'react'
import { routes } from '../../config/routes'
Expand All @@ -25,7 +26,6 @@ import {
HostMetrics,
} from '@siafoundation/explored-types'
import { Information20 } from '@siafoundation/react-icons'
import { useActiveCurrencySiascanExchangeRate } from '@siafoundation/react-core'
import LoadingCurrency from '../LoadingCurrency'
import { useExploredAddress } from '../../hooks/useExploredAddress'

Expand Down
7 changes: 5 additions & 2 deletions apps/explorer/components/Host/HostPricing.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
'use client'

import { ExplorerHost } from '@siafoundation/explored-types'
import { Text, Tooltip } from '@siafoundation/design-system'
import {
Text,
Tooltip,
useActiveCurrencySiascanExchangeRate,
} from '@siafoundation/design-system'
import {
CloudDownload16,
CloudUpload16,
Expand All @@ -13,7 +17,6 @@ import {
getStorageCost,
getUploadCost,
} from '@siafoundation/units'
import { useActiveCurrencySiascanExchangeRate } from '@siafoundation/react-core'
import LoadingCurrency from '../LoadingCurrency'
import { useExploredAddress } from '../../hooks/useExploredAddress'

Expand Down
7 changes: 5 additions & 2 deletions apps/explorer/components/Host/HostSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

import { useMemo } from 'react'
import { DatumProps, ExplorerDatum } from '../ExplorerDatum'
import { Panel, toFixedOrPrecision } from '@siafoundation/design-system'
import {
Panel,
toFixedOrPrecision,
useActiveCurrencySiascanExchangeRate,
} from '@siafoundation/design-system'
import BigNumber from 'bignumber.js'
import {
blocksToDays,
Expand All @@ -15,7 +19,6 @@ import {
getUploadCost,
} from '@siafoundation/units'
import { ExplorerHost } from '@siafoundation/explored-types'
import { useActiveCurrencySiascanExchangeRate } from '@siafoundation/react-core'
import LoadingCurrency from '../LoadingCurrency'
import { siacoinToFiat } from '../../lib/currency'
import { useExploredAddress } from '../../hooks/useExploredAddress'
Expand Down
4 changes: 2 additions & 2 deletions apps/hostd-e2e/src/fixtures/beforeTest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { mockApiSiaCentralHostsNetworkAverages } from '@siafoundation/sia-central-mock'
import { login } from './login'
import { Page } from 'playwright'
import {
Expand All @@ -11,11 +10,12 @@ import {
clickIf,
setCurrencyDisplay,
mockApiSiaScanExchangeRates,
mockApiSiaScanHostMetrics,
} from '@siafoundation/e2e'

export async function beforeTest(page: Page, { renterdCount = 0 } = {}) {
await mockApiSiaScanExchangeRates({ page })
await mockApiSiaCentralHostsNetworkAverages({ page })
await mockApiSiaScanHostMetrics({ page })
await setupCluster({ hostdCount: 1, renterdCount })
const hostdNode = clusterd.nodes.find((n) => n.type === 'hostd')
await hostdWaitForContracts({ hostdNode, renterdCount })
Expand Down
6 changes: 3 additions & 3 deletions apps/hostd/components/CmdRoot/AppCmdGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ export function AppCmdGroup({ currentPage, parentPage }: Props) {
currentPage={currentPage}
commandPage={commandPage}
onSelect={() => {
setExternalDataSettings({ siaCentral: !settings.siaCentral })
setExternalDataSettings({ siascan: !settings.siascan })
closeDialog()
}}
>
{(settings.siaCentral ? 'Disable' : 'Enable') +
' external API - Sia Central exchange rates'}
{(settings.siascan ? 'Disable' : 'Enable') +
' external API - Siascan exchange rates'}
</CommandItemSearch>
<CommandItemRootAndSearch
currentPage={currentPage}
Expand Down
2 changes: 1 addition & 1 deletion apps/hostd/contexts/config/useForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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/react-core'
import { useExchangeRate } from '@siafoundation/design-system'

export function useForm() {
const form = useHookForm({
Expand Down
4 changes: 2 additions & 2 deletions apps/renterd-e2e/src/fixtures/beforeTest.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { login } from './login'
import { Page } from 'playwright'
import { mockApiSiaCentralHostsNetworkAverages } from '@siafoundation/sia-central-mock'
import {
clusterd,
setupCluster,
Expand All @@ -11,11 +10,12 @@ import {
setCurrencyDisplay,
mockApiSiaScanExchangeRates,
clickIf,
mockApiSiaScanHostMetrics,
} from '@siafoundation/e2e'

export async function beforeTest(page: Page, { hostdCount = 0 } = {}) {
await mockApiSiaScanExchangeRates({ page })
await mockApiSiaCentralHostsNetworkAverages({ page })
await mockApiSiaScanHostMetrics({ page })
await setupCluster({ renterdCount: 1, hostdCount })
const renterdNode = clusterd.nodes.find((n) => n.type === 'renterd')
await renterdWaitForContracts({ renterdNode, hostdCount })
Expand Down
18 changes: 8 additions & 10 deletions apps/renterd-e2e/src/specs/externalData.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ import { test, expect } from '@playwright/test'
import { afterTest } from '../fixtures/beforeTest'
import { clusterd, setupCluster } from '@siafoundation/clusterd'
import { login } from '../fixtures/login'
import {
mockApiSiaCentralHostsNetworkAverages,
mockApiSiaCentralHostsNetworkAveragesHanging,
mockApiSiaCentralHostsNetworkAveragesUnroute,
} from '@siafoundation/sia-central-mock'
import { configResetBasicSettings } from '../fixtures/configResetSettings'
import {
expectTextInputByName,
Expand All @@ -15,11 +10,14 @@ import {
mockApiSiaScanExchangeRatesUnroute,
mockApiSiaScanExchangeRatesHanging,
fillSelectInputByName,
mockApiSiaScanHostMetrics,
mockApiSiaScanHostMetricsUnroute,
mockApiSiaScanHostMetricsHanging,
} from '@siafoundation/e2e'

test.beforeEach(async ({ page }) => {
await mockApiSiaScanExchangeRates({ page })
await mockApiSiaCentralHostsNetworkAverages({ page })
await mockApiSiaScanHostMetrics({ page })
await setupCluster({ renterdCount: 1 })
const renterdNode = clusterd.nodes.find((n) => n.type === 'renterd')
await login({
Expand Down Expand Up @@ -83,8 +81,8 @@ test('configuration shows not-enabled message when exchange rates API hangs', as
test('configuration does not show network averages when sia central API hangs', async ({
page,
}) => {
await mockApiSiaCentralHostsNetworkAveragesUnroute({ page })
await mockApiSiaCentralHostsNetworkAveragesHanging({ page })
await mockApiSiaScanHostMetricsUnroute({ page })
await mockApiSiaScanHostMetricsHanging({ page })
await page.reload()

await fillSelectInputByName(page, 'pinnedCurrency', 'usd')
Expand Down Expand Up @@ -120,8 +118,8 @@ test('configuration does not show network averages when sia central API hangs',
page.getByTestId('maxDownloadPriceTBGroup').getByText('Network average')
).toBeHidden()

await mockApiSiaCentralHostsNetworkAveragesUnroute({ page })
await mockApiSiaCentralHostsNetworkAverages({ page })
await mockApiSiaScanHostMetricsUnroute({ page })
await mockApiSiaScanHostMetrics({ page })
await page.reload()

// Regular field should be shown.
Expand Down
6 changes: 3 additions & 3 deletions apps/renterd/components/CmdRoot/AppCmdGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ export function AppCmdGroup({ currentPage, parentPage }: Props) {
currentPage={currentPage}
commandPage={commandPage}
onSelect={() => {
setExternalDataSettings({ siaCentral: !settings.siaCentral })
setExternalDataSettings({ siascan: !settings.siascan })
closeDialog()
}}
>
{(settings.siaCentral ? 'Disable' : 'Enable') +
' external API - Sia Central exchange rates'}
{(settings.siascan ? 'Disable' : 'Enable') +
' external API - Siascan exchange rates'}
</CommandItemSearch>
<CommandItemRootAndSearch
currentPage={currentPage}
Expand Down
2 changes: 1 addition & 1 deletion apps/renterd/components/Config/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import {
ConfigurationSiacoin,
PanelMenuSection,
PanelMenuSetting,
useExchangeRate,
} from '@siafoundation/design-system'
import { useConfig } from '../../contexts/config'
import { StateConnError } from './StateConnError'
import { ShouldPinSwitch } from './ShouldPinSwitch'
import { PinnedCurrencyWarning } from './PinnedCurrencyWarning'
import { useExchangeRate } from '@siafoundation/react-core'

export function Config() {
const { form, fields, remoteError, configRef } = useConfig()
Expand Down
32 changes: 22 additions & 10 deletions apps/renterd/components/Hosts/HostMap/Globe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { useEffect, useRef, useCallback, useMemo } from 'react'
import { GlobeMethods } from 'react-globe.gl'
import { getHostLabel } from './utils'
import { useElementSize } from 'usehooks-ts'
import { useTryUntil, useExchangeRate } from '@siafoundation/react-core'
import { useTryUntil } from '@siafoundation/react-core'
import { useExchangeRate } from '@siafoundation/design-system'
import earthDarkContrast from '../../../assets/earth-dark-contrast.png'
import earthTopology from '../../../assets/earth-topology.png'
import { GlobeDyn } from './GlobeDyn'
Expand Down Expand Up @@ -74,7 +75,12 @@ export function Globe({
return false
}

moveToLocation(activeHost?.location || [48.8323, 2.4075], 1.5)
moveToLocation(
activeHost?.location
? [activeHost.location.latitude, activeHost.location.longitude]
: [48.8323, 2.4075],
1.5
)

const directionalLight = globeEl.current
?.scene()
Expand Down Expand Up @@ -121,10 +127,10 @@ export function Globe({
arcLabel={(r: Route) =>
getHostLabel({ host: r.dst, exchangeRateUSD: exchangeRateUSD.rate })
}
arcStartLat={(r: Route) => +r.src.location[0]}
arcStartLng={(r: Route) => +r.src.location[1]}
arcEndLat={(r: Route) => +r.dst.location[0]}
arcEndLng={(r: Route) => +r.dst.location[1]}
arcStartLat={(r: Route) => +r.src.location.latitude}
arcStartLng={(r: Route) => +r.src.location.longitude}
arcEndLat={(r: Route) => +r.dst.location.latitude}
arcEndLng={(r: Route) => +r.dst.location.longitude}
arcDashLength={0.75}
arcAltitude={0}
arcDashGap={0.1}
Expand All @@ -143,8 +149,8 @@ export function Globe({
// }}
arcsTransitionDuration={0}
pointsData={points}
pointLat={(h: HostDataWithLocation) => h.location[0]}
pointLng={(h: HostDataWithLocation) => h.location[1]}
pointLat={(h: HostDataWithLocation) => h.location.latitude}
pointLng={(h: HostDataWithLocation) => h.location.longitude}
pointLabel={(h: HostDataWithLocation) =>
getHostLabel({ host: h, exchangeRateUSD: exchangeRateUSD.rate })
}
Expand Down Expand Up @@ -186,13 +192,19 @@ export function Globe({
if (!h) {
return
}
onHostHover?.(h.publicKey, h.location)
onHostHover?.(h.publicKey, [
h.location.latitude,
h.location.longitude,
])
}}
onPointClick={(h: HostDataWithLocation) => {
if (!h) {
return
}
onHostClick?.(h.publicKey, h.location)
onHostClick?.(h.publicKey, [
h.location.latitude,
h.location.longitude,
])
}}
pointsMerge={false}
/>
Expand Down
Loading

0 comments on commit a03cce0

Please sign in to comment.