package rest import ( "net/http" eth "custodial/pkg/eth" store "custodial/pkg/store" trc "custodial/pkg/tron" gin "github.com/gin-gonic/gin" ) type SpenderBalanceResponse struct { Tron trc.TronAccountBalance Ethereum eth.EthAccountBalance AccountsCount int `json:"accounts_count"` } // @BasePath /api/v1 // // AccountBalance godoc // // @Summary Check spender status // @Schemes // @Description Check spender accounts // @Tags Account // @Accept json // @Security ApiKeyAuth // @Produce json // @Success 200 {object} SpenderBalanceResponse // @Failure 400 {object} ErrorResponse // @Router /account/spender-status [get] func AccountSpenderStatusV1(c *gin.Context) { ethAccount, _ := eth.GetSpender() trcAccount, _ := trc.GetSpender() tronBalance, err := trc.TronBalance(trcAccount.Address()) if err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) return } ethBalance, err := eth.EthBalance(ethAccount.Address().String()) if err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) return } count, err := store.CountAccounts(store.Ethereum) if err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) return } c.JSON(http.StatusOK, gin.H{ "tron": tronBalance, "ethereum": ethBalance, "accounts_count": count, }) }