(c *gin.Context)
| 112 | } |
| 113 | |
| 114 | func databaseBalance(c *gin.Context) { |
| 115 | r := struct { |
| 116 | Database proto.DatabaseID `json:"db" form:"db" uri:"db" binding:"required,len=64"` |
| 117 | }{} |
| 118 | |
| 119 | _ = c.ShouldBindUri(&r) |
| 120 | |
| 121 | if err := c.ShouldBind(&r); err != nil { |
| 122 | abortWithError(c, http.StatusBadRequest, err) |
| 123 | return |
| 124 | } |
| 125 | |
| 126 | developer := getDeveloperID(c) |
| 127 | p, err := model.GetMainAccount(model.GetDB(c), developer) |
| 128 | if err != nil { |
| 129 | _ = c.Error(err) |
| 130 | abortWithError(c, http.StatusForbidden, ErrNoMainAccount) |
| 131 | return |
| 132 | } |
| 133 | |
| 134 | var profile *types.SQLChainProfile |
| 135 | if profile, err = getDatabaseProfile(r.Database); err != nil { |
| 136 | _ = c.Error(err) |
| 137 | abortWithError(c, http.StatusInternalServerError, ErrSendETLSRPCFailed) |
| 138 | return |
| 139 | } |
| 140 | |
| 141 | accountAddr, err := p.Account.Get() |
| 142 | if err != nil { |
| 143 | _ = c.Error(err) |
| 144 | abortWithError(c, http.StatusBadRequest, ErrParseAccountFailed) |
| 145 | return |
| 146 | } |
| 147 | |
| 148 | for _, user := range profile.Users { |
| 149 | if user.Address == accountAddr { |
| 150 | responseWithData(c, http.StatusOK, gin.H{ |
| 151 | "deposit": user.Deposit, |
| 152 | "arrears": user.Arrears, |
| 153 | "advance_payment": user.AdvancePayment, |
| 154 | }) |
| 155 | return |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | abortWithError(c, http.StatusForbidden, ErrNotAuthorizedAdmin) |
| 160 | } |
| 161 | |
| 162 | func databasePricing(c *gin.Context) { |
| 163 |
nothing calls this directly
no test coverage detected