Skip to content

Commit

Permalink
feat: add API to check user signature (#936)
Browse files Browse the repository at this point in the history
* fetch user info by address

* remove signature
  • Loading branch information
charymalloju authored Dec 11, 2023
1 parent 47972a8 commit 68a2515
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions server/handler/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,30 @@ import (

"github.com/labstack/echo/v4"
"github.com/vitwit/resolute/server/model"
"github.com/vitwit/resolute/server/schema"
)

func (h *Handler) GetUser(c echo.Context) error {
address := c.Param("address")

row := h.DB.QueryRow(`SELECT address, pub_key FROM users where address=$1`, address)

var userDetails schema.Users

if err := row.Scan(
&userDetails.Address,
&userDetails.PubKey,
); err != nil {
return c.JSON(http.StatusOK, model.SuccessResponse{
Data: nil,
})
}

return c.JSON(http.StatusOK, model.SuccessResponse{
Data: userDetails,
})
}

func (h *Handler) CreateUserSignature(c echo.Context) error {
address := c.Param("address")

Expand Down
1 change: 1 addition & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func main() {

// users
e.POST("/users/:address/signature", h.CreateUserSignature)
e.GET("/users/:address", h.GetUser)

e.GET("/tokens-info", h.GetTokensInfo)
e.GET("/tokens-info/:denom", h.GetTokenInfo)
Expand Down

0 comments on commit 68a2515

Please sign in to comment.