Skip to content

Commit

Permalink
Merge pull request #329 from EpicsDAO/feature
Browse files Browse the repository at this point in the history
fix - auto update solana version notification
  • Loading branch information
POPPIN-FUMI authored Oct 25, 2024
2 parents 1f3997f + 738b58c commit 38cf0c7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
12 changes: 12 additions & 0 deletions .changeset/eight-beans-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@epics-dao/solv': patch
---

fix - auto update solana version notification

=== ✨ solv updated to the latest version ✨ ===
Validator Address: xxxxxxxx
solv Version: 4.6.13
Solana Version: 2.0.14
Network: Testnet
isNodeRestartRequired: false
9 changes: 9 additions & 0 deletions packages/solv/src/cli/epochTimer/getSolanaVersion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { spawnSync } from 'node:child_process'

const getSolanaVersion = (): string => {
const { stdout } = spawnSync('solana --version', { shell: true })
const version = stdout ? String(stdout) : 'Unknown'
return version.trim()
}

export default getSolanaVersion
3 changes: 2 additions & 1 deletion packages/solv/src/cli/update/autoUpdate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { getSolanaAddress } from '@/lib/getSolanaAddress'
import sleep from '@/lib/sleep'
import { DefaultConfigType } from '@/config/types'
import { Network } from '@/config/enums'
import getSolanaVersion from '@/cli/epochTimer/getSolanaVersion'

// NODE_RESTART_REQUIRED_MAINNET/TESTNET is a boolean
// This is a global variable that is not defined in this file
Expand All @@ -22,7 +23,7 @@ const autoUpdate = async (config: DefaultConfigType) => {
const isMainnet = config.NETWORK === Network.MAINNET
const { mainnetValidatorKey, testnetValidatorKey } = getAllKeyPaths()
const validatorKey = isMainnet ? mainnetValidatorKey : testnetValidatorKey
const solanaVersion = getSolvVersion()
const solanaVersion = getSolanaVersion()
// Notify the user about the update
let isUpdateRequired = isMainnet
? NODE_RESTART_REQUIRED_MAINNET
Expand Down
9 changes: 9 additions & 0 deletions packages/solv/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { swapCommand } from './cli/swap'
import readConfig from './config/readConfig'
import { jupiterCommands } from './cli/jupiter'
import chalk from 'chalk'
import getSolanaVersion from './cli/epochTimer/getSolanaVersion'

export const program = new Command()
program
Expand Down Expand Up @@ -119,6 +120,14 @@ async function main() {
showConfig()
})

program
.command('vv')
.description('Show Solv Version')
.action(() => {
const version = getSolanaVersion()
console.log('version:', version)
})

await program
.addHelpCommand('help [cmd]', 'Display help for command')
.parseAsync(process.argv)
Expand Down

0 comments on commit 38cf0c7

Please sign in to comment.