Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.
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
1 change: 1 addition & 0 deletions main/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ async function setup (ctx) {
await fs.writeFile(filePath, logs.get())
}
}

await maybeMigrateFiles()
await start(ctx)
}
Expand Down
5 changes: 5 additions & 0 deletions main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const { ipcMain } = require('electron/main')
const os = require('os')
const core = require('./core')
const wallet = require('./wallet')
const settings = require('./settings')
const serve = require('electron-serve')
const { setupAppMenu } = require('./app-menu')
const setupTray = require('./tray')
Expand Down Expand Up @@ -122,6 +123,9 @@ const ctx = {

manualCheckForUpdates: () => { throw new Error('never get here') },
saveModuleLogsAs: () => { 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') },
showUI: () => { throw new Error('never get here') },
isShowingUI: false,
loadWebUIFromDist: serve({
Expand Down Expand Up @@ -173,6 +177,7 @@ async function run () {
await wallet.setup(ctx)
await telemetry.setup()
await core.setup(ctx)
await settings.setup(ctx)
} catch (e) {
handleError(e)
}
Expand Down
20 changes: 20 additions & 0 deletions main/ipc.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,26 @@ function setupIpcMain (/** @type {Context} */ ctx) {
'station:showTermsOfService',
(_events) => ctx.showTermsOfService()
)
ipcMain.handle(
'station:toggleOpenAtLogin',
(_events) => ctx.toggleOpenAtLogin()
)
ipcMain.handle(
'station:isOpenAtLogin',
(_events) => ctx.isOpenAtLogin()
)
ipcMain.handle(
'station:exportSeedPhrase',
(_events) => ctx.exportSeedPhrase()
)
ipcMain.handle(
'station:saveModuleLogsAs',
(_events) => ctx.saveModuleLogsAs()
)
ipcMain.handle(
'station:checkForUpdates',
(_events) => ctx.manualCheckForUpdates()
)
}

module.exports = {
Expand Down
8 changes: 7 additions & 1 deletion main/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ contextBridge.exposeInMainWorld('electron', {
getScheduledRewards: () =>
ipcRenderer.invoke('station:getScheduledRewards'),
showTermsOfService: () =>
ipcRenderer.invoke('station:showTermsOfService')
ipcRenderer.invoke('station:showTermsOfService'),
toggleOpenAtLogin: () =>
ipcRenderer.invoke('station:toggleOpenAtLogin'),
isOpenAtLogin: () => ipcRenderer.invoke('station:isOpenAtLogin'),
exportSeedPhrase: () => ipcRenderer.invoke('station:exportSeedPhrase'),
saveModuleLogsAs: () => ipcRenderer.invoke('station:saveModuleLogsAs'),
checkForUpdates: () => ipcRenderer.invoke('station:checkForUpdates')
},
stationEvents: {
onActivityLogged: (/** @type {(value: Activity) => void} */ callback) => {
Expand Down
38 changes: 38 additions & 0 deletions main/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
'use strict'

const { app, clipboard } = require('electron')
const wallet = require('./wallet')
const { showDialogSync } = require('./dialog')

/** @typedef {import('./typings').Context} Context */

/**
* @param {Context} ctx
*/
async function setup (ctx) {
ctx.toggleOpenAtLogin = () => {
const openAtLogin = !app.getLoginItemSettings().openAtLogin
app.setLoginItemSettings({ openAtLogin })
}

ctx.isOpenAtLogin = () => {
return app.getLoginItemSettings().openAtLogin
}

ctx.exportSeedPhrase = async () => {
const button = showDialogSync({
title: 'Export Seed Phrase',
// eslint-disable-next-line max-len
message: 'The seed phrase is used in order to back up your wallet, or move it to a different machine. Please be cautious, as anyone with access to it has full control over your wallet and funds.',
type: 'info',
buttons: ['Cancel', 'Copy to Clipboard']
})
if (button === 1) {
clipboard.writeText(await wallet.getSeedPhrase())
}
}
}

module.exports = {
setup
}
41 changes: 1 addition & 40 deletions main/tray.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
'use strict'

const { IS_MAC, STATION_VERSION } = require('./consts')
const { Menu, Tray, app, ipcMain, nativeImage, clipboard } = require('electron')
const { Menu, Tray, app, ipcMain, nativeImage } = require('electron')
const { ipcMainEvents } = require('./ipc')
const path = require('path')
const assert = require('node:assert')
const core = require('./core')
const { formatTokenValue } = require('./utils')
const { getSeedPhrase } = require('./wallet')
const { showDialogSync } = require('./dialog')

/** @typedef {import('./typings').Context} Context */

Expand Down Expand Up @@ -78,49 +76,12 @@ const createContextMenu = (/** @type {Context} */ ctx) => {
enabled: false
},
{ type: 'separator' },
{
id: 'checkForUpdates',
label: 'Check for Updates...',
click: () => { ctx.manualCheckForUpdates() }
},
{
id: 'checkingForUpdates',
label: 'Checking for Updates',
enabled: false,
visible: false
},
{
label: 'Save Module Logs As…',
click: function () {
ctx.saveModuleLogsAs()
}
},
{
label: 'Export Seed Phrase…',
click: async () => {
const button = showDialogSync({
title: 'Export Seed Phrase',
// eslint-disable-next-line max-len
message: 'The seed phrase is used in order to back up your wallet, or move it to a different machine. Please be cautious, as anyone with access to it has full control over your wallet and funds.',
type: 'info',
buttons: ['Cancel', 'Copy to Clipboard']
})
if (button === 1) {
clipboard.writeText(await getSeedPhrase())
}
}
},
{ type: 'separator' },
{
label: 'Start at login',
type: 'checkbox',
click: function (item) {
const openAtLogin = !app.getLoginItemSettings().openAtLogin
app.setLoginItemSettings({ openAtLogin })
item.checked = openAtLogin
},
checked: app.getLoginItemSettings().openAtLogin
},
{ type: 'separator' },
{
label: 'Quit Station',
Expand Down
4 changes: 4 additions & 0 deletions main/typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ export interface Context {

transactionUpdate: (transactions: (FILTransaction|FILTransactionProcessing)[]) => void;
balanceUpdate: (balance:string) => void;

toggleOpenAtLogin: () => void;
isOpenAtLogin: () => boolean;
exportSeedPhrase: () => void;
}

export interface WalletSeed {
Expand Down
20 changes: 20 additions & 0 deletions renderer/src/lib/station-config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,23 @@ export function openBeryx (): void {
export function showTermsOfService (): void {
return window.electron.stationConfig.showTermsOfService()
}

export function toggleOpenAtLogin () {
return window.electron.stationConfig.toggleOpenAtLogin()
}

export function isOpenAtLogin () {
return window.electron.stationConfig.isOpenAtLogin()
}

export function exportSeedPhrase () {
return window.electron.stationConfig.exportSeedPhrase()
}

export function saveModuleLogsAs () {
return window.electron.stationConfig.saveModuleLogsAs()
}

export function checkForUpdates () {
return window.electron.stationConfig.checkForUpdates()
}
30 changes: 26 additions & 4 deletions renderer/src/pages/settings/Settings.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,40 @@
import { useEffect, useState } from 'react'
import {
checkForUpdates,
exportSeedPhrase,
isOpenAtLogin,
saveModuleLogsAs,
toggleOpenAtLogin
} from 'src/lib/station-config'

const Settings = () => {
const [isOpenAtLoginChecked, setIsOpenAtLoginChecked] = useState(true)

const updateIsOpenAtLogin = async () => setIsOpenAtLoginChecked(await isOpenAtLogin())

async function handleClick () {
toggleOpenAtLogin()
setIsOpenAtLoginChecked(!isOpenAtLoginChecked)
}

useEffect(() => {
updateIsOpenAtLogin()
}, [])

return (
<div className="px-20">
<h1 className="font-bold mb-6">Settings</h1>
<h2>General</h2>
<div className="flex flex-col items-start mb-6">
<label>
<input type="checkbox" name="startAtLogin"/>
<input type="checkbox" onChange={handleClick} checked={isOpenAtLoginChecked} />
Start at login
</label>
<button type="button">Check for updates</button>
<button type="button">Save module logs as...</button>
<button type="button" onClick={checkForUpdates}>Check for updates</button>
<button type="button" onClick={saveModuleLogsAs}>Save module logs as...</button>
</div>
<h2>Security</h2>
<button type="button">Export seed phrase</button>
<button type="button" onClick={exportSeedPhrase}>Export seed phrase</button>
</div>
)
}
Expand Down
5 changes: 5 additions & 0 deletions renderer/src/typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ declare global {
transferAllFundsToDestinationWallet: () => Promise<void>;
browseTransactionTracker: (transactionHash: string) => void;
showTermsOfService: () => void;
toggleOpenAtLogin: () => void;
isOpenAtLogin: () => Promise<boolean>;
exportSeedPhrase: () => void;
saveModuleLogsAs: () => void;
checkForUpdates: () => void;
};
stationEvents: {
onActivityLogged: (callback: (activity: Activity) => void) => () => void;
Expand Down