fix issue 247 (#263)

* fix issue 247

* fix bug
fix_issue_266
LuttyYang 3 years ago committed by GitHub
parent 8561dc3c3e
commit 82cb96dc52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      cmd/subcommands/root.go

@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/harmony-one/go-sdk/pkg/address"
"net/http"
"os"
"path"
@ -223,15 +224,21 @@ func endpointToChainID(nodeAddr string) chainIDWrapper {
func validateAddress(cmd *cobra.Command, args []string) error {
// Check if input valid one address
address := oneAddress{}
if err := address.Set(args[0]); err != nil {
tmpAddr := oneAddress{}
if err := tmpAddr.Set(args[0]); err != nil {
// Check if input is valid account name
if acc, err := store.AddressFromAccountName(args[0]); err == nil {
addr = oneAddress{acc}
return nil
}
return fmt.Errorf("Invalid one address/Invalid account name: %s", args[0])
bech32Addr := address.ToBech32(address.Parse(args[0]))
if bech32Addr == "" {
return fmt.Errorf("Invalid one address/Invalid account name: %s", args[0])
}
tmpAddr = oneAddress{bech32Addr}
}
addr = address
addr = tmpAddr
return nil
}

Loading…
Cancel
Save