mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-06 19:06:42 +01:00
Fix api resopnse format for recommended fee
This commit is contained in:
@@ -7,7 +7,9 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/hermeznetwork/hermez-node/db/historydb"
|
||||
"github.com/hermeznetwork/hermez-node/log"
|
||||
"github.com/hermeznetwork/tracerr"
|
||||
"github.com/lib/pq"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -25,6 +27,9 @@ const (
|
||||
|
||||
// 2^64 /2 -1
|
||||
maxInt64 = 9223372036854775807
|
||||
|
||||
// Error for duplicated key
|
||||
errDuplicatedKey = "Item already exists"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -33,6 +38,15 @@ var (
|
||||
)
|
||||
|
||||
func retSQLErr(err error, c *gin.Context) {
|
||||
log.Warn("HTTP API SQL request error", "err", err)
|
||||
if sqlErr, ok := tracerr.Unwrap(err).(*pq.Error); ok {
|
||||
// https://www.postgresql.org/docs/current/errcodes-appendix.html
|
||||
if sqlErr.Code == "23505" {
|
||||
c.JSON(http.StatusInternalServerError, errorMsg{
|
||||
Message: errDuplicatedKey,
|
||||
})
|
||||
}
|
||||
}
|
||||
if tracerr.Unwrap(err) == sql.ErrNoRows {
|
||||
c.JSON(http.StatusNotFound, errorMsg{
|
||||
Message: err.Error(),
|
||||
@@ -45,6 +59,7 @@ func retSQLErr(err error, c *gin.Context) {
|
||||
}
|
||||
|
||||
func retBadReq(err error, c *gin.Context) {
|
||||
log.Warn("HTTP API Bad request error", "err", err)
|
||||
c.JSON(http.StatusBadRequest, errorMsg{
|
||||
Message: err.Error(),
|
||||
})
|
||||
|
||||
@@ -2193,6 +2193,11 @@ components:
|
||||
description: Recommended fee if the destination account of the transaction doesn't exist, but the coordinator has the ability to create a valid account associated to a BJJ public key controlled by the receiver. Note that these kind of accounts are not associated with an Ethereum address and therefore can only operate in L2.
|
||||
minimum: 0
|
||||
example: 0.5
|
||||
required:
|
||||
- existingAccount
|
||||
- createAccount
|
||||
- createAccountInternal
|
||||
additionalProperties: false
|
||||
Token:
|
||||
type: object
|
||||
description: Hermez Network compatible and registered token.
|
||||
|
||||
@@ -22,9 +22,9 @@ var FeeFactorLsh60 [256]*big.Int
|
||||
// the coordinator according to the tx type (if the tx requires to create an
|
||||
// account and register, only register or he account already esists)
|
||||
type RecommendedFee struct {
|
||||
ExistingAccount float64
|
||||
CreatesAccount float64
|
||||
CreatesAccountAndRegister float64
|
||||
ExistingAccount float64 `json:"existingAccount"`
|
||||
CreatesAccount float64 `json:"createAccount"`
|
||||
CreatesAccountAndRegister float64 `json:"createAccountInternal"`
|
||||
}
|
||||
|
||||
// FeeSelector is used to select a percentage from the FeePlan.
|
||||
|
||||
Reference in New Issue
Block a user