package rest import ( "net/http" eth "custodial/pkg/eth" store "custodial/pkg/store" gin "github.com/gin-gonic/gin" ) type EthAddressBalanceRequest struct { Address string `json:"address"` } type EthAccountBalanceRequest struct { AccountID string `json:"account_id"` } // @BasePath /api/v1 // // EthAddressBalance godoc // // @Summary Get eth address balance // @Schemes // @Description Get address balance // @Tags Ethereum // @Accept json // @Produce json // @Security ApiKeyAuth // @Param message body EthAddressBalanceRequest true "Account Info" // @Success 200 {object} eth.EthAccountBalance // @Failure 400 {object} ErrorResponse // @Router /eth/address-balance [post] func EthAddressBalanceV1(c *gin.Context) { var req TronAddressBalanceRequest if err := c.ShouldBindJSON(&req); err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) return } balance, err := eth.EthBalance(req.Address) if err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) return } c.JSON(http.StatusOK, balance) } // @BasePath /api/v1 // // EthAccountBalance godoc // // @Summary Get account balance // @Schemes // @Description Get account balance // @Tags Ethereum // @Accept json // @Produce json // @Security ApiKeyAuth // @Param message body EthAccountBalanceRequest true "Account Info" // @Success 200 {object} eth.EthAccountBalance // @Failure 400 {object} ErrorResponse // @Router /eth/account-balance [post] func EthAccountBalanceV1(c *gin.Context) { var req EthAccountBalanceRequest if err := c.ShouldBindJSON(&req); err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) return } storedAccount, err := store.GetAccount(req.AccountID, store.Ethereum) if err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) return } balance, err := eth.EthBalance(storedAccount.GetAddress()) if err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) return } c.JSON(http.StatusOK, balance) }