(tokenName string)
| 66 | } |
| 67 | |
| 68 | func showTokenBalance(tokenName string) { |
| 69 | var ( |
| 70 | tokenBalance uint64 |
| 71 | err error |
| 72 | ) |
| 73 | |
| 74 | tokenType := types.FromString(tokenName) |
| 75 | |
| 76 | if !tokenType.Listed() { |
| 77 | values := make([]string, len(types.TokenList)) |
| 78 | for i := types.Particle; i < types.SupportTokenNumber; i++ { |
| 79 | values[i] = types.TokenList[i] |
| 80 | } |
| 81 | ConsoleLog.Errorf("no such token supporting in CovenantSQL (what we support: %s)", |
| 82 | strings.Join(values, ", ")) |
| 83 | SetExitStatus(1) |
| 84 | return |
| 85 | } |
| 86 | if tokenBalance, err = client.GetTokenBalance(tokenType); err != nil { |
| 87 | if strings.Contains(err.Error(), "no such token balance") { |
| 88 | fmt.Println("Your account is not created in the TestNet, please apply tokens from our faucet first.") |
| 89 | } else { |
| 90 | ConsoleLog.WithError(err).Error("get token balance failed") |
| 91 | SetExitStatus(1) |
| 92 | return |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | fmt.Printf("%s balance is: %d\n", tokenType, tokenBalance) |
| 97 | } |
| 98 | |
| 99 | func showAllTokenBalance() { |
| 100 | var ( |
no test coverage detected