Skip to content

Commit

Permalink
feat: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
scorpiotzh committed Jul 9, 2024
1 parent 51c1c27 commit 9d8314e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
8 changes: 4 additions & 4 deletions dao/t_did_cell_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ func (d *DbDao) QueryDidCell(args string, didType tables.DidCellStatus, limit, o
sql := d.db.Where(" args= ?", args)
timestamp := tables.GetDidCellRecycleExpiredAt()
if didType == tables.DidCellStatusNormal {
sql.Where("expired_at > ", timestamp)
sql.Where("expired_at > ?", timestamp)
} else if didType == tables.DidCellStatusExpired {
sql.Where("expired_at <= ", timestamp)
sql.Where("expired_at <= ?", timestamp)
}
if limit > 0 {
err = sql.Limit(limit).Offset(offset).Find(&didList).Error
Expand All @@ -125,9 +125,9 @@ func (d *DbDao) QueryDidCellTotal(args string, didType tables.DidCellStatus) (co
sql := d.db.Model(tables.TableDidCellInfo{}).Where(" args= ?", args)
timestamp := tables.GetDidCellRecycleExpiredAt()
if didType == tables.DidCellStatusNormal {
sql.Where("expired_at > ", timestamp)
sql.Where("expired_at > ?", timestamp)
} else if didType == tables.DidCellStatusExpired {
sql.Where("expired_at <= ", timestamp)
sql.Where("expired_at <= ?", timestamp)
}
err = sql.Count(&count).Error
return
Expand Down
18 changes: 15 additions & 3 deletions http_server/handle/did_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/dotbitHQ/das-lib/core"
"github.com/dotbitHQ/das-lib/http_api"
"github.com/gin-gonic/gin"
"github.com/nervosnetwork/ckb-sdk-go/address"
"github.com/scorpiotzh/toolib"
"net/http"
)
Expand Down Expand Up @@ -78,16 +79,27 @@ func (h *HttpHandle) doDidList(ctx context.Context, req *ReqDidList, apiResp *ht
var resp RespDidList
data := make([]DidData, 0)

args := ""
addrHex, err := req.FormatChainTypeAddress(h.DasCore.NetType(), true)
if err != nil {
apiResp.ApiRespErr(http_api.ApiCodeParamsInvalid, "address invalid")
return fmt.Errorf("FormatChainTypeAddress err: %s", err.Error())
if req.KeyInfo.CoinType == common.CoinTypeCKB {
if addrP, err := address.Parse(req.KeyInfo.Key); err == nil {
args = common.Bytes2Hex(addrP.Script.Args)
} else {
apiResp.ApiRespErr(http_api.ApiCodeParamsInvalid, "address invalid")
return fmt.Errorf("FormatChainTypeAddress err: %s", err.Error())
}
} else {
apiResp.ApiRespErr(http_api.ApiCodeParamsInvalid, "address invalid")
return fmt.Errorf("FormatChainTypeAddress err: %s", err.Error())
}
} else if addrHex.DasAlgorithmId != common.DasAlgorithmIdAnyLock {
apiResp.ApiRespErr(http_api.ApiCodeParamsInvalid, "address invalid")
return nil
} else {
args = common.Bytes2Hex(addrHex.ParsedAddress.Script.Args)
}

args := common.Bytes2Hex(addrHex.ParsedAddress.Script.Args)
res, err := h.DbDao.QueryDidCell(args, req.DidType, req.GetLimit(), req.GetOffset())
if err != nil {
apiResp.ApiRespErr(http_api.ApiCodeDbError, "search did cell list err")
Expand Down

0 comments on commit 9d8314e

Please sign in to comment.