diff --git a/.changeset/tidy-dogs-know.md b/.changeset/tidy-dogs-know.md new file mode 100644 index 0000000..b0861e4 --- /dev/null +++ b/.changeset/tidy-dogs-know.md @@ -0,0 +1,33 @@ +--- +'@epics-dao/solv': patch +--- + +Update - solv update --migrate-config + +## Summary + +This PR adds a new command `solv update --migrate-config` to migrate the old config file to the new config file. + +`solv.config.json` to `solv4.config.json` + +You can migrate the old config file to the new config file by running the following command: + +```bash +solv update --migrate-config +``` + +## Config Update Command + +This command will update the config file to the latest version. + +```bash +solv update --config +``` + +## solv Discord Channel is now migrated to Validators DAO's Discord + +Due to the increasing number of users, the solv Discord channel has been migrated to Validators DAO's Discord. + +Now this community is more focused on Solana Validators and RPC Operators. + +Validators DAO: https://discord.gg/8dhnZnvzuw diff --git a/packages/solv/src/cli/setup/index.ts b/packages/solv/src/cli/setup/index.ts index 2fe0638..59975d0 100644 --- a/packages/solv/src/cli/setup/index.ts +++ b/packages/solv/src/cli/setup/index.ts @@ -8,6 +8,7 @@ import { readOrCreateJitoConfig } from '@/lib/readOrCreateJitoConfig' import { daemonReload } from '@/lib/daemonReload' import { setupV2 } from './setupV2' import { jitoRelayerSetup } from './jitoRelayerSetup' +import rpcLog from '@/utils/rpcLog' type SetupOptions = { vote: boolean @@ -50,11 +51,13 @@ export const setupCommands = (config: DefaultConfigType) => { ), ) daemonReload() + rpcLog() process.exit(0) } else if (options.jupiter) { console.log(chalk.white('Setting up Jupiter Swap API ...')) await jupiterAPISetup() daemonReload() + rpcLog() process.exit(0) } await setupV2(options.skipInitConfig, options.skipMount) diff --git a/packages/solv/src/cli/setup/setupV2.ts b/packages/solv/src/cli/setup/setupV2.ts index 3578f32..7caa382 100644 --- a/packages/solv/src/cli/setup/setupV2.ts +++ b/packages/solv/src/cli/setup/setupV2.ts @@ -17,6 +17,7 @@ import updateSysctlConfig from '@/template/updateSysctlConfig' import { restartLogrotate } from '@/lib/restartLogrotate' import { enableSolv } from '@/lib/enableSolv' import { createSymLink } from './createSymLink' +import rpcLog from '@/utils/rpcLog' export const setupV2 = async (skipInitConfig = false, skipMount = false) => { try { @@ -70,39 +71,8 @@ export const setupV2 = async (skipInitConfig = false, skipMount = false) => { // Start Solana startSolana() console.log(chalk.white(`🟢 Setup Completed`)) - lastMsg() + rpcLog() } catch (error: any) { throw new Error(`Setup Error: ${error.message}`) } } - -const lastMsg = () => { - const warning = `===⚠️ Frequently Asked Questions ⚠️=== -Q: How long does it take to catch up with the latest slot? -Q: Error: error sending request for url (http://localhost:8899/) -Q: Can't connect to Solana RPC Node - -A: -It will take an hour to a several hours to catch up with the latest slot. -This time may vary depending on your network speed and hardware. -Solana Validator requires at least 256GB RAM and 12 CPU cores. -RPC Node requires at least 512GB RAM and 16 CPU cores. -It may not finish catching up if your hardware does not meet the requirements. - -You can check current status by running: - -$ solv monitor - -(Above cmd only works when the snapshot is downloaded and the validator is running.) -If above cmd doesn't work, please check if your node has finished downloading the snapshot by running: - -$ solv log - -You can only track error logs by running: - -$ solv log -e - -Validators Solutions: https://validators.solutions -` - console.log(chalk.yellow(warning)) -} diff --git a/packages/solv/src/cli/setup/template/jupiter/jupiterAPISetup.ts b/packages/solv/src/cli/setup/template/jupiter/jupiterAPISetup.ts index 422b231..252f2ed 100644 --- a/packages/solv/src/cli/setup/template/jupiter/jupiterAPISetup.ts +++ b/packages/solv/src/cli/setup/template/jupiter/jupiterAPISetup.ts @@ -2,6 +2,7 @@ import { spawnSync } from 'child_process' import jupiterAPIService from '@/cli/setup/template/jupiter/jupiterAPIService' import inquirer from 'inquirer' import chalk from 'chalk' +import rpcLog from '@/utils/rpcLog' type JupiterAPISetupOptions = { rpcUrl: string diff --git a/packages/solv/src/cli/swap/index.ts b/packages/solv/src/cli/swap/index.ts index 3851197..a492962 100644 --- a/packages/solv/src/cli/swap/index.ts +++ b/packages/solv/src/cli/swap/index.ts @@ -13,6 +13,8 @@ import { swap } from './swap' import { Command } from 'commander' import { ELSOL_MINT_ADDRESS } from '@/config/config' import { DefaultConfigType } from '@/config/types' +import { updateDefaultConfig } from '@/config/updateDefaultConfig' +import rpcLog from '@/utils/rpcLog' dotenv.config() export const swapCommand = async ( @@ -63,16 +65,12 @@ const swapCmd = async ( outputMint = '', inputAmountLamport = 0, isNeedConfirm = true, + initConfig = false, ) => { console.log(chalk.white('Solana RPC URL:', solanaRpcUrl)) console.log(chalk.white('KeyfilePath:', keyfilePath)) - if (!keyfilePath || keyfilePath === '') { - console.log( - chalk.yellow( - `⚠️ Please set the KEYPAIR_PATH in the solv4.config.json file to use this command ⚠️`, - ), - ) - return + if (!keyfilePath || keyfilePath === '' || initConfig) { + await askForConfig() } const jupiterEndpoint = JUPITER_ENDPOINT let inputTokenChoice = [...SWAP_TOKENS, 'Other'] @@ -172,3 +170,35 @@ const swapCmd = async ( } export default swapCmd + +export type SwapConfig = { + RPC_URL: string + KEYPAIR_PATH: string + API_KEY: string +} + +const askForConfig = async () => { + const config = await inquirer.prompt([ + { + type: 'input', + name: 'RPC_URL', + message: 'Enter Solana RPC URL', + default: 'https://api.mainnet-beta.solana.com', + }, + { + type: 'input', + name: 'KEYPAIR_PATH', + message: 'Enter Keypair Path', + default: '/home/solv/mainnet-validator-keypair.json', + }, + { + type: 'input', + name: 'API_KEY', + message: 'Enter Jupiter API Key(Optional)', + default: '', + }, + ]) + await updateDefaultConfig(config) + console.log(chalk.green('✔︎ Config Updated Successfully!\n')) + rpcLog() +} diff --git a/packages/solv/src/cli/update/index.ts b/packages/solv/src/cli/update/index.ts index 3c64924..80ab97f 100644 --- a/packages/solv/src/cli/update/index.ts +++ b/packages/solv/src/cli/update/index.ts @@ -36,6 +36,7 @@ export type UpdateOptions = { commission: number firewall: boolean config: boolean + migrateConfig: boolean auto: boolean } @@ -64,6 +65,7 @@ export const updateCommands = (config: DefaultConfigType) => { .option('-b, --background', 'No Monitor Delinquent Stake Update', false) .option('-c, --commission', 'Update Commission', false) .option('-f, --firewall', 'Update Firewall', false) + .option('--migrate-config', 'Migrate Solv Config', false) .option('--config', 'Update Solv Config Default Solana Version', false) .option('--auto', 'Auto Update', false) .action(async (options: UpdateOptions) => { @@ -78,8 +80,8 @@ export const updateCommands = (config: DefaultConfigType) => { await autoUpdate(config) return } - // Only Update solv.config.json default solana version - if (options.config) { + + if (options.migrateConfig) { // Temporarily!! // Migrate solv.config.json to solv4.config.json const oldConfig = readOrCreateDefaultConfig().config @@ -121,7 +123,8 @@ export const updateCommands = (config: DefaultConfigType) => { await updateDefaultConfig(newConfigBody) // --- End of Temporarily!! - + } + if (options.config) { await updateDefaultConfig({ TESTNET_SOLANA_VERSION: VERSION_TESTNET, MAINNET_SOLANA_VERSION: VERSION_MAINNET, @@ -150,8 +153,8 @@ export const updateCommands = (config: DefaultConfigType) => { if (options.background) { let version = options.version await updateDefaultConfig({ - TESTNET_SOLANA_VERSION: config.TESTNET_SOLANA_VERSION, - MAINNET_SOLANA_VERSION: config.MAINNET_SOLANA_VERSION, + TESTNET_SOLANA_VERSION: VERSION_TESTNET, + MAINNET_SOLANA_VERSION: VERSION_MAINNET, }) if (isJito) { diff --git a/packages/solv/src/utils/rpcLog.ts b/packages/solv/src/utils/rpcLog.ts new file mode 100644 index 0000000..8042a22 --- /dev/null +++ b/packages/solv/src/utils/rpcLog.ts @@ -0,0 +1,19 @@ +import chalk from 'chalk' + +const rpcLog = () => { + const lighting = `${chalk.yellow('⚡️⚡️⚡️')}` + const msg = `${chalk.blueBright(`${lighting} Solana Private RPC Connection API Key ${lighting}`)} + +We're excited to offer a free API key exclusively for the Validators DAO community 🎉 +It's our way of supporting the community and empowering you with fast, reliable connections. + +To get your free API key, simply join us through the link below: + +Validators DAO: ${chalk.white('`https://discord.gg/X4BgkBHavp`')} + +Unlock fast connections and elevate your experience with your very own API key 🚀 +` + console.log(chalk.cyan(msg)) +} + +export default rpcLog