diff --git a/.changeset/ten-geckos-rest.md b/.changeset/ten-geckos-rest.md index 710b6b10d..e58135636 100644 --- a/.changeset/ten-geckos-rest.md +++ b/.changeset/ten-geckos-rest.md @@ -1,7 +1,6 @@ --- '@siafoundation/e2e': minor '@siafoundation/sia-central-mock': minor -'@siafoundation/walletd-mock': minor --- Upgraded playwright dependencies. diff --git a/README.md b/README.md index c1a62b4a0..82246ff12 100644 --- a/README.md +++ b/README.md @@ -73,8 +73,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 diff --git a/apps/hostd-e2e/src/fixtures/beforeTest.ts b/apps/hostd-e2e/src/fixtures/beforeTest.ts index 10aa42b00..951ee4a66 100644 --- a/apps/hostd-e2e/src/fixtures/beforeTest.ts +++ b/apps/hostd-e2e/src/fixtures/beforeTest.ts @@ -1,4 +1,3 @@ -import { mockApiSiaCentralHostsNetworkAverages } from '@siafoundation/sia-central-mock' import { login } from './login' import { Page } from 'playwright' import { @@ -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 }) diff --git a/apps/hostd/components/CmdRoot/AppCmdGroup.tsx b/apps/hostd/components/CmdRoot/AppCmdGroup.tsx index 4419c2e64..c53569a0c 100644 --- a/apps/hostd/components/CmdRoot/AppCmdGroup.tsx +++ b/apps/hostd/components/CmdRoot/AppCmdGroup.tsx @@ -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'} n.type === 'renterd') await renterdWaitForContracts({ renterdNode, hostdCount }) diff --git a/apps/renterd-e2e/src/specs/externalData.spec.ts b/apps/renterd-e2e/src/specs/externalData.spec.ts index 3b794dfd5..63f416a4e 100644 --- a/apps/renterd-e2e/src/specs/externalData.spec.ts +++ b/apps/renterd-e2e/src/specs/externalData.spec.ts @@ -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, @@ -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({ @@ -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') @@ -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. diff --git a/apps/renterd/components/CmdRoot/AppCmdGroup.tsx b/apps/renterd/components/CmdRoot/AppCmdGroup.tsx index c420a7ce7..3f835155b 100644 --- a/apps/renterd/components/CmdRoot/AppCmdGroup.tsx +++ b/apps/renterd/components/CmdRoot/AppCmdGroup.tsx @@ -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'} rates - ? `$${new BigNumber(host.settings?.storage_price || 0) + ? `$${new BigNumber(host.settings?.storageprice || 0) .times(TBToBytes(1)) .times(monthsToBlocks(1)) .div(1e24) .times(rates?.usd || 1) .toFixed(2)}/TB` : `${humanSiacoin( - new BigNumber(host.settings?.storage_price || 0) + new BigNumber(host.settings?.storageprice || 0) .times(TBToBytes(1)) .times(monthsToBlocks(1)), { fixed: 0 } @@ -57,13 +55,13 @@ export function HostItem({ const downloadCost = useMemo( () => rates - ? `$${new BigNumber(host.settings?.download_price || 0) + ? `$${new BigNumber(host.settings?.downloadbandwidthprice || 0) .times(TBToBytes(1)) .div(1e24) .times(rates?.usd || 1) .toFixed(2)}/TB` : `${humanSiacoin( - new BigNumber(host.settings?.download_price || 0).times( + new BigNumber(host.settings?.downloadbandwidthprice || 0).times( TBToBytes(1) ), { fixed: 0 } @@ -74,13 +72,15 @@ export function HostItem({ const uploadCost = useMemo( () => rates - ? `$${new BigNumber(host.settings?.upload_price || 0) + ? `$${new BigNumber(host.settings?.uploadbandwidthprice || 0) .times(TBToBytes(1)) .div(1e24) .times(rates?.usd || 1) .toFixed(2)}/TB` : `${humanSiacoin( - new BigNumber(host.settings?.upload_price || 0).times(TBToBytes(1)), + new BigNumber(host.settings?.uploadbandwidthprice || 0).times( + TBToBytes(1) + ), { fixed: 0 } )}/TB`, [rates, host] @@ -91,7 +91,7 @@ export function HostItem({ content={
- {countryCodeEmoji(host.country_code)} {host.country_code} + {countryCodeEmoji(host.countryCode)} {host.countryCode}
@@ -105,17 +105,6 @@ export function HostItem({ upload
-
- - {humanBytes(host.settings?.total_storage || 0)} - - - {getDownloadSpeed(host)} - - - {getUploadSpeed(host)} - -
{storageCost} @@ -130,7 +119,7 @@ export function HostItem({
} - key={host.public_key} + key={host.publicKey} > { - if (!settings.siaCentral) { + if (!settings.siascan) { openDialog('settings') return } diff --git a/apps/renterd/contexts/config/transform.spec.ts b/apps/renterd/contexts/config/transform.spec.ts index 2887dad36..c5ac8cbac 100644 --- a/apps/renterd/contexts/config/transform.spec.ts +++ b/apps/renterd/contexts/config/transform.spec.ts @@ -375,11 +375,6 @@ describe('tansforms', () => { gouging: { data: gouging }, pinned: { data: pinned }, upload: { data: upload }, - appSettings: { - settings: { - siaCentral: false, - }, - }, }, renterdState: { network: 'mainnet' as const, diff --git a/apps/renterd/contexts/config/useAverages.tsx b/apps/renterd/contexts/config/useAverages.tsx index 0ecfcf53c..3912de613 100644 --- a/apps/renterd/contexts/config/useAverages.tsx +++ b/apps/renterd/contexts/config/useAverages.tsx @@ -6,10 +6,10 @@ import { valuePerByteToPerTB, valuePerOneToPerMillion, } from '@siafoundation/units' -import { useSiaCentralHostsNetworkAverages } from '@siafoundation/sia-central-react' +import { useExternalHostMetrics } from '@siafoundation/design-system' export function useAverages() { - const siaCentralAverages = useSiaCentralHostsNetworkAverages({ + const siascanAverages = useExternalHostMetrics({ config: { swr: { revalidateOnFocus: false, @@ -18,58 +18,56 @@ export function useAverages() { }) const storageAverage = useMemo( () => - siaCentralAverages.data + siascanAverages.data ? new BigNumber( valuePerBytePerBlockToPerTBPerMonth( - toSiacoins(siaCentralAverages.data.settings.storage_price) + toSiacoins(siascanAverages.data.settings.storageprice) ).toFixed(0) ) : undefined, - [siaCentralAverages.data] + [siascanAverages.data] ) const uploadAverage = useMemo( () => - siaCentralAverages.data + siascanAverages.data ? new BigNumber( valuePerByteToPerTB( - toSiacoins(siaCentralAverages.data.settings.upload_price) + toSiacoins(siascanAverages.data.settings.uploadbandwidthprice) ).toFixed(0) ) : undefined, - [siaCentralAverages.data] + [siascanAverages.data] ) const downloadAverage = useMemo( () => - siaCentralAverages.data + siascanAverages.data ? new BigNumber( valuePerByteToPerTB( - toSiacoins(siaCentralAverages.data.settings.download_price) + toSiacoins(siascanAverages.data.settings.downloadbandwidthprice) ).toFixed(0) ) : undefined, - [siaCentralAverages.data] + [siascanAverages.data] ) const contractAverage = useMemo( () => - siaCentralAverages.data + siascanAverages.data ? new BigNumber( - toSiacoins(siaCentralAverages.data.settings.contract_price).toFixed( - 0 - ) + toSiacoins(siascanAverages.data.settings.contractprice).toFixed(0) ) : undefined, - [siaCentralAverages.data] + [siascanAverages.data] ) const rpcAverage = useMemo( () => - siaCentralAverages.data + siascanAverages.data ? valuePerOneToPerMillion( - toSiacoins(siaCentralAverages.data.settings.base_rpc_price) + toSiacoins(siascanAverages.data.settings.baserpcprice) ) : undefined, - [siaCentralAverages.data] + [siascanAverages.data] ) const averages = useMemo(() => { diff --git a/apps/renterd/contexts/config/useResources.tsx b/apps/renterd/contexts/config/useResources.tsx index 095ea2dd0..910455202 100644 --- a/apps/renterd/contexts/config/useResources.tsx +++ b/apps/renterd/contexts/config/useResources.tsx @@ -1,4 +1,4 @@ -import { useAppSettings, SWRError } from '@siafoundation/react-core' +import { SWRError } from '@siafoundation/react-core' import { AutopilotConfig, AutopilotState, @@ -53,8 +53,6 @@ export function useResources() { }, }) - const appSettings = useAppSettings() - // Resources required to intialize form. const resources: ResourcesMaybeLoaded = useMemo( () => ({ @@ -78,11 +76,6 @@ export function useResources() { data: upload.data, error: upload.error, }, - appSettings: { - settings: { - siaCentral: appSettings.settings.siaCentral, - }, - }, }), [ autopilotState.data, @@ -95,7 +88,6 @@ export function useResources() { pinned.error, upload.data, upload.error, - appSettings.settings.siaCentral, ] ) @@ -106,7 +98,6 @@ export function useResources() { gouging, pinned, upload, - appSettings, } } @@ -162,11 +153,6 @@ export type ResourcesMaybeLoaded = { data?: SettingsUpload error?: SWRError } - appSettings: { - settings: { - siaCentral: boolean - } - } } export type ResourcesRequiredLoaded = { @@ -190,9 +176,4 @@ export type ResourcesRequiredLoaded = { data: SettingsUpload error?: undefined } - appSettings: { - settings: { - siaCentral: boolean - } - } } diff --git a/apps/renterd/contexts/contracts/dataset.tsx b/apps/renterd/contexts/contracts/dataset.tsx index 67985c436..21ea1d488 100644 --- a/apps/renterd/contexts/contracts/dataset.tsx +++ b/apps/renterd/contexts/contracts/dataset.tsx @@ -2,13 +2,13 @@ import { useContracts as useContractsData } from '@siafoundation/renterd-react' import { useMemo } from 'react' import BigNumber from 'bignumber.js' import { ContractData, ContractDataWithoutPrunable } from './types' -import { useSiaCentralHosts } from '@siafoundation/sia-central-react' import { useSyncStatus } from '../../hooks/useSyncStatus' import { blockHeightToTime } from '@siafoundation/units' import { defaultDatasetRefreshInterval } from '../../config/swr' import { usePrunableContractSizes } from './usePrunableContractSizes' import { Maybe } from '@siafoundation/types' import { maybeFromNullishArrayResponse } from '@siafoundation/react-core' +import { useExternalHostsList } from '@siafoundation/design-system' export function useDataset() { const response = useContractsData({ @@ -18,8 +18,16 @@ export function useDataset() { }, }, }) - const geo = useSiaCentralHosts() - const geoHosts = useMemo(() => geo.data?.hosts || [], [geo.data]) + const geo = useExternalHostsList({ + params: { + sortBy: 'storage_price', + dir: 'asc', + }, + payload: { + online: true, + }, + }) + const geoHosts = useMemo(() => geo.data || [], [geo.data]) const syncStatus = useSyncStatus() const currentHeight = syncStatus.isSynced @@ -45,7 +53,7 @@ export function useDataset() { id: c.id, state: c.state, hostKey: c.hostKey, - location: geoHosts.find((h) => h.public_key === c.hostKey)?.location, + location: geoHosts.find((h) => h.publicKey === c.hostKey)?.location, timeline: startTime, usability: c.usability, startTime, diff --git a/apps/renterd/contexts/hosts/dataset.ts b/apps/renterd/contexts/hosts/dataset.ts index 041448210..c98f93658 100644 --- a/apps/renterd/contexts/hosts/dataset.ts +++ b/apps/renterd/contexts/hosts/dataset.ts @@ -8,10 +8,10 @@ import { useHosts, } from '@siafoundation/renterd-react' import { ContractData } from '../contracts/types' -import { SiaCentralHost } from '@siafoundation/sia-central-types' import { Maybe } from '@siafoundation/types' import { objectEntries } from '@siafoundation/design-system' import { maybeFromNullishArrayResponse } from '@siafoundation/react-core' +import { ExplorerHost } from '@siafoundation/explored-types' export function useDataset({ response, @@ -26,7 +26,7 @@ export function useDataset({ allowlist: ReturnType blocklist: ReturnType isAllowlistActive: boolean - geoHosts: SiaCentralHost[] + geoHosts: ExplorerHost[] }) { return useMemo>(() => { const data = maybeFromNullishArrayResponse(response.data) @@ -36,7 +36,7 @@ export function useDataset({ return undefined } return data.map((host) => { - const sch = geoHosts.find((gh) => gh.public_key === host.publicKey) + const sch = geoHosts.find((gh) => gh.publicKey === host.publicKey) return { ...getHostFields(host, allContracts), ...getAllowedFields({ @@ -47,7 +47,7 @@ export function useDataset({ }), ...getAutopilotFields(host.checks), location: sch?.location, - countryCode: sch?.country_code, + countryCode: sch?.countryCode, // selectable onClick: () => null, isSelected: false, diff --git a/apps/renterd/contexts/hosts/index.tsx b/apps/renterd/contexts/hosts/index.tsx index 632d054c0..519430451 100644 --- a/apps/renterd/contexts/hosts/index.tsx +++ b/apps/renterd/contexts/hosts/index.tsx @@ -2,6 +2,7 @@ import { triggerToast, truncate, useDatasetState, + useExternalHostsList, useMultiSelect, usePaginationOffset, useServerFilters, @@ -18,7 +19,6 @@ import { HostsPayload, HostsUsabilityMode, } from '@siafoundation/renterd-types' -import { useSiaCentralHosts } from '@siafoundation/sia-central-react' import { createContext, useCallback, @@ -91,22 +91,23 @@ function useHostsMain() { const isAllowlistActive = !!allowlist.data?.length const { settings } = useAppSettings() - const geo = useSiaCentralHosts({ - disabled: !settings.siaCentral, - config: { - swr: { - revalidateOnFocus: false, - }, + const geo = useExternalHostsList({ + params: { + sortBy: 'storage_price', + dir: 'asc', + }, + payload: { + online: true, }, }) useEffect(() => { - if (!settings.siaCentral) { + if (!settings.siascan) { setViewMode('list') } - }, [settings.siaCentral]) + }, [settings.siascan]) - const geoHosts = useMemo(() => geo.data?.hosts || [], [geo.data]) + const geoHosts = useMemo(() => geo.data || [], [geo.data]) const cmdRef = useRef(emptyCommands) diff --git a/apps/walletd-e2e/src/fixtures/beforeTest.ts b/apps/walletd-e2e/src/fixtures/beforeTest.ts index 0f5a0459e..01eca7fa1 100644 --- a/apps/walletd-e2e/src/fixtures/beforeTest.ts +++ b/apps/walletd-e2e/src/fixtures/beforeTest.ts @@ -1,6 +1,5 @@ import { login } from './login' import { Page } from 'playwright' -import { mockApiSiaCentralHostsNetworkAverages } from '@siafoundation/sia-central-mock' import { clusterd, mine, @@ -11,6 +10,7 @@ import { Bus } from '@siafoundation/renterd-js' import { setCurrencyDisplay, mockApiSiaScanExchangeRates, + mockApiSiaScanHostMetrics, } from '@siafoundation/e2e' export async function beforeTest( @@ -18,7 +18,7 @@ export async function beforeTest( { siafundAddr }: { siafundAddr?: string } = {} ) { await mockApiSiaScanExchangeRates({ page }) - await mockApiSiaCentralHostsNetworkAverages({ page }) + await mockApiSiaScanHostMetrics({ page }) await setupCluster({ walletdCount: 1, renterdCount: 1, diff --git a/libs/walletd-mock/src/mocks/consensusNetwork.ts b/apps/walletd/lib/mocks/mockConsensusNetwork.ts similarity index 100% rename from libs/walletd-mock/src/mocks/consensusNetwork.ts rename to apps/walletd/lib/mocks/mockConsensusNetwork.ts diff --git a/libs/walletd-mock/src/mocks/consensusTipState.ts b/apps/walletd/lib/mocks/mockConsensusTipState.ts similarity index 100% rename from libs/walletd-mock/src/mocks/consensusTipState.ts rename to apps/walletd/lib/mocks/mockConsensusTipState.ts diff --git a/libs/walletd-mock/src/scenarios/seedWallet.ts b/apps/walletd/lib/mocks/mockSeedWallet.ts similarity index 98% rename from libs/walletd-mock/src/scenarios/seedWallet.ts rename to apps/walletd/lib/mocks/mockSeedWallet.ts index 4a576cd39..64d698408 100644 --- a/libs/walletd-mock/src/scenarios/seedWallet.ts +++ b/apps/walletd/lib/mocks/mockSeedWallet.ts @@ -8,8 +8,8 @@ import { WalletOutputsSiafundResponse, } from '@siafoundation/walletd-types' import { toHastings } from '@siafoundation/units' -import { getMockConsensusNetworkResponse } from '../mocks/consensusNetwork' -import { getMockConsensusTipStateResponse } from '../mocks/consensusTipState' +import { getMockConsensusNetworkResponse } from './mockConsensusNetwork' +import { getMockConsensusTipStateResponse } from './mockConsensusTipState' export function getMockScenarioSeedWallet() { const mnemonic = diff --git a/apps/walletd/lib/signLedgerV1.spec.ts b/apps/walletd/lib/signLedgerV1.spec.ts index c1577308c..5ae95d71d 100644 --- a/apps/walletd/lib/signLedgerV1.spec.ts +++ b/apps/walletd/lib/signLedgerV1.spec.ts @@ -1,7 +1,7 @@ import { initSDK } from '@siafoundation/sdk' import { signTransactionLedgerV1 } from './signLedgerV1' import { getMockAddresses, getMockDevice } from './testMocks' -import { getMockScenarioSeedWallet } from '@siafoundation/walletd-mock' +import { getMockScenarioSeedWallet } from './mocks/mockSeedWallet' beforeEach(async () => { await initSDK() diff --git a/apps/walletd/lib/signSeedV1.spec.ts b/apps/walletd/lib/signSeedV1.spec.ts index 38fcd358d..a04ca38b9 100644 --- a/apps/walletd/lib/signSeedV1.spec.ts +++ b/apps/walletd/lib/signSeedV1.spec.ts @@ -1,6 +1,6 @@ import { signTransactionSeedV1 } from './signSeedV1' import { initSDK } from '@siafoundation/sdk' -import { getMockScenarioSeedWallet } from '@siafoundation/walletd-mock' +import { getMockScenarioSeedWallet } from './mocks/mockSeedWallet' import { getMockAddresses } from './testMocks' beforeEach(async () => { diff --git a/apps/walletd/lib/signSeedV2.spec.ts b/apps/walletd/lib/signSeedV2.spec.ts index 81aa4542f..5b8413346 100644 --- a/apps/walletd/lib/signSeedV2.spec.ts +++ b/apps/walletd/lib/signSeedV2.spec.ts @@ -1,6 +1,6 @@ import { signTransactionSeedV2 } from './signSeedV2' import { initSDK } from '@siafoundation/sdk' -import { getMockScenarioSeedWallet } from '@siafoundation/walletd-mock' +import { getMockScenarioSeedWallet } from './mocks/mockSeedWallet' import { getMockAddresses } from './testMocks' beforeEach(async () => { diff --git a/apps/website/components/HostMap/Globe.tsx b/apps/website/components/HostMap/Globe.tsx index a983bb85f..89fca7eb5 100644 --- a/apps/website/components/HostMap/Globe.tsx +++ b/apps/website/components/HostMap/Globe.tsx @@ -11,15 +11,15 @@ import dynamic from 'next/dynamic' import { GlobeMethods } from 'react-globe.gl' import { random, sortBy } from '@technically/lodash' import { getHostLabel } from './utils' -import { SiaCentralPartialHost } from '../../content/geoHosts' import { getAssetUrl } from '../../content/assets' import { useTheme } from 'next-themes' import { useElementSize } from 'usehooks-ts' +import { ExplorerPartialHost } from '../../content/geoHosts' type Props = { - activeHost?: SiaCentralPartialHost + activeHost?: ExplorerPartialHost selectActiveHost: (public_key: string) => void - hosts: SiaCentralPartialHost[] + hosts: ExplorerPartialHost[] rates: { usd: string } @@ -27,8 +27,8 @@ type Props = { type Route = { distance: number - src: SiaCentralPartialHost - dst: SiaCentralPartialHost + src: ExplorerPartialHost + dst: ExplorerPartialHost } const GlobeGl = dynamic(() => import('./GlobeGl'), { @@ -44,7 +44,7 @@ const ReactGlobe = forwardRef(function ReactGlobe( function GlobeComponent({ activeHost, hosts, rates, selectActiveHost }: Props) { const globeEl = useRef(null) - const moveToHost = useCallback((host: SiaCentralPartialHost) => { + const moveToHost = useCallback((host: ExplorerPartialHost) => { globeEl.current?.pointOfView( { lat: host.location[0] - 8, @@ -118,7 +118,7 @@ function GlobeComponent({ activeHost, hosts, rates, selectActiveHost }: Props) { let routes: Route[] = [] for (let i = 0; i < hosts.length; i++) { const host = hosts[i] - if (activeHost.public_key === host.public_key) { + if (activeHost.publicKey === host.publicKey) { continue } const distance = distanceBetweenHosts(activeHost, host) @@ -176,26 +176,26 @@ function GlobeComponent({ activeHost, hosts, rates, selectActiveHost }: Props) { : [`rgba(187, 229, 201, 0.10)`, `rgba(187, 229, 201, 0.10)`] } onArcClick={(r: Route) => { - selectActiveHost(r.dst.public_key) + selectActiveHost(r.dst.publicKey) }} arcsTransitionDuration={0} pointsData={hosts} - pointLat={(h: SiaCentralPartialHost) => h.location[0]} - pointLng={(h: SiaCentralPartialHost) => h.location[1]} - pointLabel={(h: SiaCentralPartialHost) => + pointLat={(h: ExplorerPartialHost) => h.location[0]} + pointLng={(h: ExplorerPartialHost) => h.location[1]} + pointLabel={(h: ExplorerPartialHost) => getHostLabel({ host: h, rates }) } pointAltitude={0} - pointColor={(h: SiaCentralPartialHost) => - h.public_key === activeHost.public_key + pointColor={(h: ExplorerPartialHost) => + h.publicKey === activeHost?.publicKey ? 'rgba(0,255,0,1)' : 'rgba(0,255,0,1)' } - pointRadius={(h: SiaCentralPartialHost) => - h.public_key === activeHost.public_key ? 0.6 : 0.2 + pointRadius={(h: ExplorerPartialHost) => + h.publicKey === activeHost?.publicKey ? 0.6 : 0.2 } - onPointClick={(h: SiaCentralPartialHost) => { - selectActiveHost(h.public_key) + onPointClick={(h: ExplorerPartialHost) => { + selectActiveHost(h.publicKey) }} pointsMerge={false} /> @@ -206,8 +206,8 @@ function GlobeComponent({ activeHost, hosts, rates, selectActiveHost }: Props) { export const Globe = memo(GlobeComponent) function distanceBetweenHosts( - h1: SiaCentralPartialHost, - h2: SiaCentralPartialHost + h1: ExplorerPartialHost, + h2: ExplorerPartialHost ) { return Math.sqrt( Math.pow(h1.location[0] - h2.location[0], 2) + @@ -215,15 +215,12 @@ function distanceBetweenHosts( ) } -function doesIncludeActiveHost( - route: Route, - activeHost?: SiaCentralPartialHost -) { +function doesIncludeActiveHost(route: Route, activeHost?: ExplorerPartialHost) { if (!activeHost) { return false } return ( - route.dst.public_key === activeHost.public_key || - route.src.public_key === activeHost.public_key + route.dst.publicKey === activeHost.publicKey || + route.src.publicKey === activeHost.publicKey ) } diff --git a/apps/website/components/HostMap/HostItem.tsx b/apps/website/components/HostMap/HostItem.tsx index 3d8eabcb4..28051f541 100644 --- a/apps/website/components/HostMap/HostItem.tsx +++ b/apps/website/components/HostMap/HostItem.tsx @@ -9,20 +9,18 @@ import { } from '@siafoundation/design-system' import { cx } from 'class-variance-authority' import BigNumber from 'bignumber.js' -import { SiaCentralPartialHost } from '../../content/geoHosts' +import { ExplorerPartialHost } from '../../content/geoHosts' import { Launch16 } from '@siafoundation/react-icons' import { monthsToBlocks, TBToBytes, humanBytes, humanSiacoin, - getDownloadSpeed, - getUploadSpeed, } from '@siafoundation/units' type Props = { - host: SiaCentralPartialHost - activeHost?: SiaCentralPartialHost + host: ExplorerPartialHost + activeHost?: ExplorerPartialHost setRef?: (el: HTMLButtonElement) => void selectActiveHost: (public_key: string) => void rates: { @@ -40,14 +38,14 @@ export function HostItem({ const storageCost = useMemo( () => rates - ? `$${new BigNumber(host.settings.storage_price) + ? `$${new BigNumber(host.settings.storageprice) .times(TBToBytes(1)) .times(monthsToBlocks(1)) .div(1e24) .times(rates?.usd || 1) .toFixed(2)}/TB` : `${humanSiacoin( - new BigNumber(host.settings.storage_price) + new BigNumber(host.settings.storageprice) .times(TBToBytes(1)) .times(monthsToBlocks(1)), { fixed: 0 } @@ -58,13 +56,15 @@ export function HostItem({ const downloadCost = useMemo( () => rates - ? `$${new BigNumber(host.settings.download_price) + ? `$${new BigNumber(host.settings.downloadbandwidthprice) .times(TBToBytes(1)) .div(1e24) .times(rates?.usd || 1) .toFixed(2)}/TB` : `${humanSiacoin( - new BigNumber(host.settings.download_price).times(TBToBytes(1)), + new BigNumber(host.settings.downloadbandwidthprice).times( + TBToBytes(1) + ), { fixed: 0 } )}/TB`, [rates, host] @@ -73,13 +73,15 @@ export function HostItem({ const uploadCost = useMemo( () => rates - ? `$${new BigNumber(host.settings.upload_price) + ? `$${new BigNumber(host.settings.uploadbandwidthprice) .times(TBToBytes(1)) .div(1e24) .times(rates?.usd || 1) .toFixed(2)}/TB` : `${humanSiacoin( - new BigNumber(host.settings.upload_price).times(TBToBytes(1)), + new BigNumber(host.settings.uploadbandwidthprice).times( + TBToBytes(1) + ), { fixed: 0 } )}/TB`, [rates, host] @@ -96,14 +98,14 @@ export function HostItem({ weight="bold" className="text-start" > - {countryCodeEmoji(host.country_code)} {host.country_code} + {countryCodeEmoji(host.countryCode)} {host.countryCode} @@ -120,17 +122,6 @@ export function HostItem({ upload
-
- - {humanBytes(host.settings.total_storage)} - - - {getDownloadSpeed(host)} - - - {getUploadSpeed(host)} - -
{storageCost} @@ -145,7 +136,7 @@ export function HostItem({
} - key={host.public_key} + key={host.publicKey} >