import { Answer, NetworkValue } from './models/choice' import { showTitleAndBanner } from './utils/logger.util' import { networkQuestion } from './questions/network.question' import { nodeTypeQuestion } from './questions/note_type.question' import { ddcNodeActions } from './actions' import { filePath, mainnet, testnet, devnet } from './constants.json' import { AppConfig } from './models/app_config' import { filePathConfig } from './models/file_path' import { WalletCreation } from './questions/wallet/wallet_creation' import { getProviderEmail } from './questions/email/email.question' import { confirmCountryGuessQuestion, countryQuestion } from './questions/country_question' import { getCountryCodeFromCountryName, getCountryCodeFromTimezone } from './templates/location/detect_node_location' import { stakeQuestion } from './questions/ddc_staking/ask_stake.question' export async function CGX(): Promise { showTitleAndBanner() const autoDetectedCountry = await confirmCountryGuessQuestion() let nodeCountryCode: string if (autoDetectedCountry.confirmCountryGuess === 'no' || autoDetectedCountry.confirmCountryGuess === 'n') { const country = await countryQuestion() nodeCountryCode = getCountryCodeFromCountryName(country.nodeCountry) } else { nodeCountryCode = getCountryCodeFromTimezone() } const email: string = await getProviderEmail() const { seedPhrase, walletAddress } = await WalletCreation() const networkAnswer: Answer = await networkQuestion() const nodeAnswer: Answer = await nodeTypeQuestion() let network: AppConfig switch (networkAnswer.network) { case NetworkValue.MAINNET: network = mainnet as AppConfig break case NetworkValue.TESTNET: network = testnet as AppConfig break case NetworkValue.DEVNET: network = devnet as AppConfig break default: throw new Error(`Unknown network ${networkAnswer.network}`) } const stakeAnswer = await stakeQuestion(nodeAnswer.nodeType, network) await ddcNodeActions({ appConf: network, filePathConf: filePath as filePathConfig, nodeType: nodeAnswer.nodeType, seedPhrase: seedPhrase, walletAddress: walletAddress, email: email, nodeCountryISOCode: nodeCountryCode, clusterId: stakeAnswer.clusterId, }) return }