MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / showTokenBalance

Function showTokenBalance

cmd/cql/internal/wallet.go:68–97  ·  view source on GitHub ↗
(tokenName string)

Source from the content-addressed store, hash-verified

66}
67
68func 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
99func showAllTokenBalance() {
100 var (

Callers 1

runWalletFunction · 0.85

Calls 10

FromStringFunction · 0.92
GetTokenBalanceFunction · 0.92
SetExitStatusFunction · 0.85
ListedMethod · 0.80
ErrorfMethod · 0.80
ContainsMethod · 0.80
ErrorMethod · 0.80
PrintlnMethod · 0.80
WithErrorMethod · 0.80
PrintfMethod · 0.45

Tested by

no test coverage detected