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

Function GetTokenBalance

client/driver.go:324–352  ·  view source on GitHub ↗

GetTokenBalance get the token balance of current account.

(tt types.TokenType)

Source from the content-addressed store, hash-verified

322
323// GetTokenBalance get the token balance of current account.
324func GetTokenBalance(tt types.TokenType) (balance uint64, err error) {
325 if atomic.LoadUint32(&driverInitialized) == 0 {
326 err = ErrNotInitialized
327 return
328 }
329
330 req := new(types.QueryAccountTokenBalanceReq)
331 resp := new(types.QueryAccountTokenBalanceResp)
332
333 var pubKey *asymmetric.PublicKey
334 if pubKey, err = kms.GetLocalPublicKey(); err != nil {
335 return
336 }
337
338 if req.Addr, err = crypto.PubKeyHash(pubKey); err != nil {
339 return
340 }
341 req.TokenType = tt
342
343 if err = requestBP(route.MCCQueryAccountTokenBalance, req, resp); err == nil {
344 if !resp.OK {
345 err = ErrNoSuchTokenBalance
346 return
347 }
348 balance = resp.Balance
349 }
350
351 return
352}
353
354// UpdatePermission sends UpdatePermission transaction to chain.
355func UpdatePermission(targetUser proto.AccountAddress,

Callers 5

StableCoinBalanceMethod · 0.92
CovenantCoinBalanceMethod · 0.92
showTokenBalanceFunction · 0.92
showAllTokenBalanceFunction · 0.92
TestGetTokenBalanceFunction · 0.85

Calls 3

GetLocalPublicKeyFunction · 0.92
PubKeyHashFunction · 0.92
requestBPFunction · 0.85

Tested by 1

TestGetTokenBalanceFunction · 0.68