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

Function getBalance

cmd/cql-proxy/api/account.go:141–171  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

139}
140
141func getBalance(c *gin.Context) {
142 developer := getDeveloperID(c)
143 p, err := model.GetMainAccount(model.GetDB(c), developer)
144 if err != nil {
145 _ = c.Error(err)
146 abortWithError(c, http.StatusForbidden, ErrNoMainAccount)
147 return
148 }
149
150 var (
151 req = new(types.QueryAccountTokenBalanceReq)
152 resp = new(types.QueryAccountTokenBalanceResp)
153 )
154
155 req.Addr, err = p.Account.Get()
156 if err != nil {
157 _ = c.Error(err)
158 abortWithError(c, http.StatusBadRequest, ErrParseAccountFailed)
159 return
160 }
161
162 if err = rpc.RequestBP(route.MCCQueryAccountTokenBalance.String(), req, resp); err != nil {
163 _ = c.Error(err)
164 abortWithError(c, http.StatusInternalServerError, ErrSendETLSRPCFailed)
165 return
166 }
167
168 responseWithData(c, http.StatusOK, gin.H{
169 "balance": resp.Balance,
170 })
171}
172
173func setMainAccount(c *gin.Context) {
174 r := struct {

Callers

nothing calls this directly

Calls 8

GetMainAccountFunction · 0.92
GetDBFunction · 0.92
getDeveloperIDFunction · 0.85
abortWithErrorFunction · 0.85
responseWithDataFunction · 0.85
ErrorMethod · 0.80
GetMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected