Skip to content

Commit

Permalink
various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
batphonghan committed Jan 10, 2024
1 parent d1924f2 commit 67fac08
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
5 changes: 4 additions & 1 deletion shared/utils/cli/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@ func Select(initialPrompt string, options []string) (int, string) {

// Get prompt
prompt := initialPrompt
errPromptMsg := "Please enter a number corresponding to an option"

for i, option := range options {
prompt += fmt.Sprintf("\n%d: %s", (i + 1), option)
errPromptMsg += fmt.Sprintf("\n%d: %s", (i + 1), option)
}

// Get expected response format
Expand All @@ -70,7 +73,7 @@ func Select(initialPrompt string, options []string) (int, string) {
expectedFormat := fmt.Sprintf("^(%s)$", strings.Join(optionNumbers, "|"))

// Prompt user
response := Prompt(prompt, expectedFormat, "Please enter a number corresponding to an option")
response := Prompt(prompt, expectedFormat, errPromptMsg)

// Get selected option
index, _ := strconv.Atoi(response)
Expand Down
7 changes: 3 additions & 4 deletions stader-cli/node/utilize-sd.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Maximum utilization amount: %s
%sPlease enter the amount of SD you wish to utilize from the SD Utility Pool:%s`, eth.DisplayAmountInUnits(sdStatus.PoolAvailableSDBalance, "sd"), eth.DisplayAmountInUnits(minUtility, "sd"), eth.DisplayAmountInUnits(maxUtility, "sd"), log.ColorYellow, log.ColorReset)

errMsg := fmt.Sprintf("Invalid input, please specify an amount within %f and %f SD range\n", minSd, maxSd)
errMsg := fmt.Sprintf("Invalid input, please specify an amount within %f and %f SD range", minSd, maxSd)

utilityAmount, err := sd.PromptChooseSDWithMaxMin(msg, errMsg, minUtility, maxUtility)
if err != nil {
Expand All @@ -161,13 +161,12 @@ func PromptChooseSelfBondAmount(sdStatus *api.SdStatusResponse) (*big.Int, error
minSd := eth.WeiToEth(amountToCollateralRemain)
maxSd := eth.WeiToEth(sdRewardEligibleRemain)

msg := fmt.Sprintf(`
Minimum bond: %s
msg := fmt.Sprintf(`Minimum bond: %s
Maximum bond: %s
%sPlease enter the amount of SD you wish to deposit as collateral:%s`, eth.DisplayAmountInUnits(amountToCollateralRemain, "sd"), eth.DisplayAmountInUnits(sdRewardEligibleRemain, "sd"), log.ColorYellow, log.ColorReset)

errMsg := fmt.Sprintf("Invalid input, please specify an amount within %f and %f SD range\n", minSd, maxSd)
errMsg := fmt.Sprintf("Invalid input, please specify an amount within %f and %f SD range", minSd, maxSd)

utilityAmount, err := sd.PromptChooseSDWithMaxMin(msg, errMsg, amountToCollateralRemain, sdRewardEligibleRemain)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions stader-cli/validator/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,9 @@ func nodeDeposit(c *cli.Context) error {
return nil
}

autoConfirm := c.Bool("yes")
nounce := c.GlobalUint64("nonce")
err = node.DepositSdWithAmount(staderClient, selfBondAmount, true, nounce)

err = node.DepositSdWithAmount(staderClient, selfBondAmount, autoConfirm, nounce)
if err != nil {
return err
}
Expand Down

0 comments on commit 67fac08

Please sign in to comment.