package generate import ( "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util" "github.com/spf13/cobra" "github.com/spf13/viper" ) const ( storageWalletLabelFlag = "label" storageGasCLIFlag = "initial-gas" storageGasConfigFlag = "storage.initial_gas" walletAddressFlag = "wallet-address" ) var ( GenerateStorageCmd = &cobra.Command{ Use: "generate-storage-wallet", Short: "Generate storage node wallet for the morph network", PreRun: func(cmd *cobra.Command, _ []string) { _ = viper.BindPFlag(util.AlphabetWalletsFlag, cmd.Flags().Lookup(util.AlphabetWalletsFlag)) _ = viper.BindPFlag(util.EndpointFlag, cmd.Flags().Lookup(util.EndpointFlag)) _ = viper.BindPFlag(storageGasConfigFlag, cmd.Flags().Lookup(storageGasCLIFlag)) }, RunE: generateStorageCreds, } RefillGasCmd = &cobra.Command{ Use: "refill-gas", Short: "Refill GAS of storage node's wallet in the morph network", PreRun: func(cmd *cobra.Command, _ []string) { _ = viper.BindPFlag(util.AlphabetWalletsFlag, cmd.Flags().Lookup(util.AlphabetWalletsFlag)) _ = viper.BindPFlag(util.EndpointFlag, cmd.Flags().Lookup(util.EndpointFlag)) _ = viper.BindPFlag(util.RefillGasAmountFlag, cmd.Flags().Lookup(util.RefillGasAmountFlag)) }, RunE: func(cmd *cobra.Command, args []string) error { return refillGas(cmd, util.RefillGasAmountFlag, false) }, } GenerateAlphabetCmd = &cobra.Command{ Use: "generate-alphabet", Short: "Generate alphabet wallets for consensus nodes of the morph network", PreRun: func(cmd *cobra.Command, _ []string) { // PreRun fixes https://github.com/spf13/viper/issues/233 _ = viper.BindPFlag(util.AlphabetWalletsFlag, cmd.Flags().Lookup(util.AlphabetWalletsFlag)) }, RunE: AlphabetCreds, } ) func initRefillGasCmd() { RefillGasCmd.Flags().String(util.AlphabetWalletsFlag, "", util.AlphabetWalletsFlagDesc) RefillGasCmd.Flags().StringP(util.EndpointFlag, util.EndpointFlagShort, "", util.EndpointFlagDesc) RefillGasCmd.Flags().String(util.StorageWalletFlag, "", "Path to storage node wallet") RefillGasCmd.Flags().String(walletAddressFlag, "", "Address of wallet") RefillGasCmd.Flags().String(util.RefillGasAmountFlag, "", "Additional amount of GAS to transfer") RefillGasCmd.MarkFlagsMutuallyExclusive(walletAddressFlag, util.StorageWalletFlag) } func initGenerateStorageCmd() { GenerateStorageCmd.Flags().String(util.AlphabetWalletsFlag, "", util.AlphabetWalletsFlagDesc) GenerateStorageCmd.Flags().StringP(util.EndpointFlag, util.EndpointFlagShort, "", util.EndpointFlagDesc) GenerateStorageCmd.Flags().String(util.StorageWalletFlag, "", "Path to new storage node wallet") GenerateStorageCmd.Flags().String(storageGasCLIFlag, "", "Initial amount of GAS to transfer") GenerateStorageCmd.Flags().StringP(storageWalletLabelFlag, "l", "", "Wallet label") } func initGenerateAlphabetCmd() { GenerateAlphabetCmd.Flags().String(util.AlphabetWalletsFlag, "", util.AlphabetWalletsFlagDesc) GenerateAlphabetCmd.Flags().Uint(util.AlphabetSizeFlag, 7, "Amount of alphabet wallets to generate") } func init() { initRefillGasCmd() initGenerateStorageCmd() initGenerateAlphabetCmd() }