mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 11:26:44 +01:00
Refactor account creation auth endpoints
This commit is contained in:
@@ -28,46 +28,6 @@ var (
|
||||
ErrNillBidderAddr = errors.New("biderAddr can not be nil")
|
||||
)
|
||||
|
||||
func postAccountCreationAuth(c *gin.Context) {
|
||||
// Parse body
|
||||
var apiAuth accountCreationAuthAPI
|
||||
if err := c.ShouldBindJSON(&apiAuth); err != nil {
|
||||
retBadReq(err, c)
|
||||
return
|
||||
}
|
||||
// API to common + verify signature
|
||||
dbAuth, err := accountCreationAuthAPIToCommon(&apiAuth)
|
||||
if err != nil {
|
||||
retBadReq(err, c)
|
||||
return
|
||||
}
|
||||
// Insert to DB
|
||||
if err := l2.AddAccountCreationAuth(dbAuth); err != nil {
|
||||
retSQLErr(err, c)
|
||||
return
|
||||
}
|
||||
// Return OK
|
||||
c.Status(http.StatusOK)
|
||||
}
|
||||
|
||||
func getAccountCreationAuth(c *gin.Context) {
|
||||
// Get hezEthereumAddress
|
||||
addr, err := parseParamHezEthAddr(c)
|
||||
if err != nil {
|
||||
retBadReq(err, c)
|
||||
return
|
||||
}
|
||||
// Fetch auth from l2DB
|
||||
dbAuth, err := l2.GetAccountCreationAuth(*addr)
|
||||
if err != nil {
|
||||
retSQLErr(err, c)
|
||||
return
|
||||
}
|
||||
apiAuth := accountCreationAuthToAPI(dbAuth)
|
||||
// Build succesfull response
|
||||
c.JSON(http.StatusOK, apiAuth)
|
||||
}
|
||||
|
||||
func getAccounts(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user