Skip to content

Commit

Permalink
module -> subnet
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangruber committed Feb 11, 2025
1 parent 403ef8d commit 68b982d
Show file tree
Hide file tree
Showing 19 changed files with 74 additions and 74 deletions.
File renamed without changes.
4 changes: 2 additions & 2 deletions main/app-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ function setupAppMenu (/** @type {import('./typings').Context} */ ctx) {

// File menu
menu.items[1].submenu?.insert(0, new MenuItem({
label: 'Save Module Logs As…',
click: () => { ctx.saveModuleLogsAs() }
label: 'Save Subnet Logs As…',
click: () => { ctx.saveSubnetLogsAs() }
}))

Menu.setApplicationMenu(menu)
Expand Down
4 changes: 2 additions & 2 deletions main/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ let totalJobsCompleted = 0
* @param {Context} ctx
*/
async function setup (ctx) {
ctx.saveModuleLogsAs = async () => {
ctx.saveSubnetLogsAs = async () => {
const opts = {
defaultPath: `checker-modules-${(new Date()).getTime()}.log`
defaultPath: `checker-subnets-${(new Date()).getTime()}.log`
}
// The dialog might not show if the UI is hidden
ctx.showUI()
Expand Down
2 changes: 1 addition & 1 deletion main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const ctx = {
getWalletBalance: () => wallet.getBalance(),

manualCheckForUpdates: () => { throw new Error('never get here') },
saveModuleLogsAs: () => { throw new Error('never get here') },
saveSubnetLogsAs: () => { throw new Error('never get here') },
toggleOpenAtLogin: () => { throw new Error('never get here') },
isOpenAtLogin: () => { throw new Error('never get here') },
exportSeedPhrase: () => { throw new Error('never get here') },
Expand Down
4 changes: 2 additions & 2 deletions main/ipc.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ function setupIpcMain (/** @type {Context} */ ctx) {
(_events) => ctx.exportSeedPhrase()
)
ipcMain.handle(
'checker:saveModuleLogsAs',
(_events) => ctx.saveModuleLogsAs()
'checker:saveSubnetLogsAs',
(_events) => ctx.saveSubnetLogsAs()
)
ipcMain.handle(
'checker:checkForUpdates',
Expand Down
2 changes: 1 addition & 1 deletion main/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ contextBridge.exposeInMainWorld('electron', {
ipcRenderer.invoke('checker:toggleOpenAtLogin'),
isOpenAtLogin: () => ipcRenderer.invoke('checker:isOpenAtLogin'),
exportSeedPhrase: () => ipcRenderer.invoke('checker:exportSeedPhrase'),
saveModuleLogsAs: () => ipcRenderer.invoke('checker:saveModuleLogsAs'),
saveSubnetLogsAs: () => ipcRenderer.invoke('checker:saveSubnetLogsAs'),
checkForUpdates: () => ipcRenderer.invoke('checker:checkForUpdates')
},
checkerEvents: {
Expand Down
2 changes: 1 addition & 1 deletion main/typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export interface Context {
isShowingUI: boolean;
loadWebUIFromDist: import('electron-serve').loadURL;
manualCheckForUpdates: () => void;
saveModuleLogsAs: () => Promise<void>;
saveSubnetLogsAs: () => Promise<void>;

openReleaseNotes: () => void;
restartToUpdate: () => void;
Expand Down
4 changes: 2 additions & 2 deletions renderer/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ROUTES } from 'src/lib/routes'
import Layout from 'src/components/Layout'
import Settings from 'src/pages/settings/Settings'
import Wallet from 'src/pages/wallet/Wallet'
import Modules from 'src/pages/modules/Modules'
import Subnets from 'src/pages/subnets/Subnets'
import { DialogProvider } from './components/DialogProvider'
import { TooltipProvider } from '@radix-ui/react-tooltip'

Expand All @@ -34,7 +34,7 @@ const App = ():JSX.Element => {
<Route path={ROUTES.dashboard} element={<Dashboard />} />
<Route path={ROUTES.wallet} element={<Wallet />} />
<Route path={ROUTES.settings} element={<Settings />} />
<Route path={ROUTES.modules} element={<Modules />} />
<Route path={ROUTES.subnets} element={<Subnets />} />
</Routes>
</Layout>
}
Expand Down
File renamed without changes
8 changes: 4 additions & 4 deletions renderer/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useState } from 'react'
import { NavLink } from 'react-router'
import { ROUTES } from 'src/lib/routes'
import HomeIcon from 'src/assets/img/icons/home.svg?react'
import ModulesIcon from 'src/assets/img/icons/modules.svg?react'
import SubnetsIcon from 'src/assets/img/icons/subnets.svg?react'
import WalletIcon from 'src/assets/img/icons/wallet.svg?react'
import SettingsIcon from 'src/assets/img/icons/settings.svg?react'
import MenuArrow from 'src/assets/img/icons/menu-arrow.svg?react'
Expand All @@ -17,9 +17,9 @@ const links = [
Icon: HomeIcon
},
{
href: ROUTES.modules,
title: 'Modules',
Icon: ModulesIcon
href: ROUTES.subnets,
title: 'Subnets',
Icon: SubnetsIcon
},
{
href: ROUTES.wallet,
Expand Down
20 changes: 10 additions & 10 deletions renderer/src/hooks/Subnets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import SparkLogo from 'src/assets/img/icons/spark-logo.png'
import SaturnLogo from 'src/assets/img/icons/saturn-logo.svg'

/**
* @returns {Promise<string>} The contract address of the Spark module
* @returns {Promise<string>} The contract address of the Spark subnet
*/
async function getSparkContractAddress () {
const name = Name.parse(
Expand Down Expand Up @@ -82,7 +82,7 @@ async function getSparkTransfersFromStats () {
}

/**
* @returns {Promise<number>} The total rewards of the Spark module
* @returns {Promise<number>} The total rewards of the Spark subnet
*/
async function getSparkTotalRewards () {
const [balanceHeld, transfersFromStats] = await Promise.all([
Expand All @@ -94,7 +94,7 @@ async function getSparkTotalRewards () {
}

/* eslint-disable max-len */
export const modules = {
export const subnets = {
spark: {
name: 'Spark',
description: 'Spark is a trustless protocol for sampling retrievals from Filecoin Storage Providers. Spark aims to drive improvements in the retrievability of data stored on Filecoin.',
Expand Down Expand Up @@ -131,9 +131,9 @@ export const modules = {
}
} as const

export type Module = (typeof modules)[keyof typeof modules] & {id: string}
export type Subnet = (typeof subnets)[keyof typeof subnets] & {id: string}

export const useModules = () => {
export const useSubnets = () => {
const [sparkContractAddress, setSparkContractAddress] = useState<string>()
const [sparkTotalRewards, setSparkTotalRewards] = useState<number>(0)

Expand All @@ -151,19 +151,19 @@ export const useModules = () => {
load()
}, [])

const modulesUpdated = {
...modules,
const subnetsUpdated = {
...subnets,
spark: {
...modules.spark,
...subnets.spark,
contractAddress: sparkContractAddress,
stats: {
...modules.spark.stats,
...subnets.spark.stats,
totalRewards: sparkTotalRewards
}
}
}

return {
modules: Object.entries(modulesUpdated).map(([id, mod]) => ({ ...mod, id })) as Module[]
subnets: Object.entries(subnetsUpdated).map(([id, subnet]) => ({ ...subnet, id })) as Subnet[]
}
}
4 changes: 2 additions & 2 deletions renderer/src/lib/checker-config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ export function exportSeedPhrase () {
return window.electron.checkerConfig.exportSeedPhrase()
}

export function saveModuleLogsAs () {
return window.electron.checkerConfig.saveModuleLogsAs()
export function saveSubnetLogsAs () {
return window.electron.checkerConfig.saveSubnetLogsAs()
}

export function checkForUpdates () {
Expand Down
2 changes: 1 addition & 1 deletion renderer/src/lib/routes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const ROUTES = {
onboarding: '/',
dashboard: '/dashboard',
modules: '/modules',
subnets: '/subnets',
settings: '/settings',
wallet: '/wallet'
} as const
16 changes: 8 additions & 8 deletions renderer/src/pages/dashboard/ChartController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ function getDataInTimeRange (data: RewardsRecord[], timeRange: TimeRange) {

const ChartController = ({ historicalRewards }: {historicalRewards: RewardsRecord[]}) => {
const [timeRange, setTimeRange] = useState<TimeRange>('7d')
const [moduleId, setModuleId] = useState('all')
const [subnetId, setSubnetId] = useState('all')

const filteredHistoricalRewards = useMemo(
() => getDataInTimeRange(historicalRewards, timeRange),
[timeRange, historicalRewards]
)

const moduleIdsInRange = useMemo(
const subnetIdsInRange = useMemo(
() => filteredHistoricalRewards.reduce<string[]>(
(acc, record) => [
...acc,
...Object.keys(record.totalScheduledRewards).filter((id) => !acc.includes(id))
], ['All modules']
], ['All subnets']
), [filteredHistoricalRewards])

return (
Expand All @@ -61,13 +61,13 @@ const ChartController = ({ historicalRewards }: {historicalRewards: RewardsRecor
))}
</ToggleGroup>
<Select
label='Module'
label='Subnet'
onValueChange={(value) => {
setModuleId(value === 'All modules' ? 'all' : value)
setSubnetId(value === 'All subnets' ? 'all' : value)
}}
defaultValue='All modules'
defaultValue='All subnets'
>
{moduleIdsInRange.map((id) => (
{subnetIdsInRange.map((id) => (
<SelectItem
label={id}
value={id}
Expand All @@ -77,7 +77,7 @@ const ChartController = ({ historicalRewards }: {historicalRewards: RewardsRecor
</Select>
</div>
<section className='px-2 flex-1 flex'>
<Chart historicalRewards={filteredHistoricalRewards} moduleId={moduleId} timeRange={timeRange} />
<Chart historicalRewards={filteredHistoricalRewards} subnetId={subnetId} timeRange={timeRange} />
</section>
</div>
)
Expand Down
10 changes: 5 additions & 5 deletions renderer/src/pages/settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
checkForUpdates,
exportSeedPhrase,
isOpenAtLogin,
saveModuleLogsAs,
saveSubnetLogsAs,
toggleOpenAtLogin
} from 'src/lib/checker-config'
import SettingsGroup, { SettingsGroupItem } from './SettingsGroup'
Expand Down Expand Up @@ -61,18 +61,18 @@ const Settings = () => {
}
/>
<SettingsGroupItem
title='Module logs'
description={`Saving module logs in the Station app helps users track
title='Subnet logs'
description={`Saving subnet logs in the Station app helps users track
and diagnose issues, providing insights into the performance of individual
components for effective troubleshooting.`}
input={
<Button
type='button'
variant='secondary'
icon={<SaveIcon />}
onClick={saveModuleLogsAs}
onClick={saveSubnetLogsAs}
>
Save module logs as...
Save subnet logs as...
</Button>
}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { ReactNode } from 'react'
import Tag from 'src/components/Tag'
import Text from 'src/components/Text'
import { Module } from 'src/hooks/Subnets'
import { Subnet } from 'src/hooks/Subnets'
import GithubIcon from 'src/assets/img/icons/github.svg?react'
import DocsIcon from 'src/assets/img/icons/docs.svg?react'
import ExplorerIcon from 'src/assets/img/icons/explorer.svg?react'
import { openExplorerLink } from 'src/lib/utils'
import { openExternalURL } from 'src/lib/checker-config'

const ModuleLink = ({ children, onClick }: {children: ReactNode; onClick: () => void}) => (
const SubnetLink = ({ children, onClick }: {children: ReactNode; onClick: () => void}) => (
<Text
as='button'
type='button'
Expand All @@ -20,7 +20,7 @@ const ModuleLink = ({ children, onClick }: {children: ReactNode; onClick: () =>
</Text>
)

const moduleStatus = {
const subnetStatus = {
active: {
tagStatus: 'primary',
text: 'Active'
Expand All @@ -31,60 +31,60 @@ const moduleStatus = {
}
} as const

const ModuleCard = ({ module }: {module: Module}) => {
const SubnetCard = ({ subnet }: {subnet: Subnet}) => {
return (
<div className='bg-slate-50 border border-dashed border-slate-400 rounded-xl animate-fadeIn'>
<div className='h-[276px] flex border-b border-dashed border-slate-400'>
<div className='py-9 px-5 flex flex-col gap-3 justify-between'>
<Text as='h2' size="l" font='mono'>{module.name}</Text>
<Text as='h2' size="l" font='mono'>{subnet.name}</Text>
<Text as='p' size="xs" className='text-pretty no-overflow-text line-clamp-6'>
{module.description}
{subnet.description}
</Text>
<div className='mt-auto'>
<Tag type={moduleStatus[module.status].tagStatus}>{moduleStatus[module.status].text}</Tag>
<Tag type={subnetStatus[subnet.status].tagStatus}>{subnetStatus[subnet.status].text}</Tag>
</div>
</div>
<figure
className={
`flex w-[140px] shrink-0 py-9 px-5 border-l border-dashed border-slate-400
bg-${module.logoBackgroundColor} rounded-tr-xl
bg-${subnet.logoBackgroundColor} rounded-tr-xl
`}
>
<img src={module.logo} alt={`${module.name}'s logo`} className='max-w-[100px] m-auto' />
<img src={subnet.logo} alt={`${subnet.name}'s logo`} className='max-w-[100px] m-auto' />
</figure>
</div>
<div className='flex py-9 px-5'>
<div className='w-3/5 flex flex-col gap-5'>
<div className='flex flex-col'>
<Text font='mono' size="3xs" color='primary' uppercase>&#47;&#47; Rewards given ... :</Text>
<Text font='mono' size="xs">
{module.stats.rewardsEnabled
? `${module.stats.totalRewards || '...'} FIL`
{subnet.stats.rewardsEnabled
? `${subnet.stats.totalRewards || '...'} FIL`
: (<sub>coming soon</sub>)}
</Text>
</div>
<div className='flex flex-col'>
<Text font='mono' size="3xs" color='primary' uppercase>&#47;&#47; # Jobs done ... :</Text>
<Text font='mono' size="xs">{module.stats.totalJobs || (<sub>coming soon</sub>)}</Text>
<Text font='mono' size="xs">{subnet.stats.totalJobs || (<sub>coming soon</sub>)}</Text>
</div>
</div>
<div className='flex flex-col gap-6 w-2/5'>
<ModuleLink onClick={() => openExternalURL(module.links.github) }>
<SubnetLink onClick={() => openExternalURL(subnet.links.github) }>
<GithubIcon className='text-primary' />
Github
</ModuleLink>
<ModuleLink onClick={() => openExternalURL(module.links.docs) }>
</SubnetLink>
<SubnetLink onClick={() => openExternalURL(subnet.links.docs) }>
<DocsIcon className='text-primary' />
Docs
</ModuleLink>
<ModuleLink onClick={() => openExplorerLink(module.contractAddress) }>
</SubnetLink>
<SubnetLink onClick={() => openExplorerLink(subnet.contractAddress) }>
<ExplorerIcon className='text-primary' />
Explorer
</ModuleLink>
</SubnetLink>
</div>
</div>
</div>
)
}

export default ModuleCard
export default SubnetCard
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { useModules } from 'src/hooks/Subnets'
import ModuleCard from './ModuleCard'
import { useSubnets } from 'src/hooks/Subnets'
import SubnetCard from './SubnetCard'
import Text from 'src/components/Text'

const Modules = () => {
const { modules } = useModules()
const Subnets = () => {
const { subnets } = useSubnets()

return (
<main className='px-9 mt-28 flex flex-col w-[1000px] max-w-full mx-auto'>
<header className='mb-9'>
<Text as='h1' font='mono' size='xs' color='primary' uppercase>&#47;&#47; Modules ... :</Text>
<Text as='h1' font='mono' size='xs' color='primary' uppercase>&#47;&#47; Subnets ... :</Text>
</header>
<section className='grid gap-8 grid-cols-2'>
{modules?.map(module => <ModuleCard module={module} key={module.id} />)}
{subnets?.map(subnet => <SubnetCard subnet={subnet} key={subnet.id} />)}
</section>
</main>
)
}

export default Modules
export default Subnets
Loading

0 comments on commit 68b982d

Please sign in to comment.