Skip to content

Commit

Permalink
Merge branch 'docs' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
scorpiotzh committed Jul 9, 2024
2 parents 01ab6ef + 51c1c27 commit 7a05b22
Show file tree
Hide file tree
Showing 21 changed files with 94 additions and 88 deletions.
18 changes: 11 additions & 7 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* [Get Batch Account Records Info](#get-batch-account-records-info)
* [Get Batch Reverse Record Info](#Get-Batch-Reverse-Record-Info)
* [Get Batch register Info](#get-batch-register-info)
* [Get Did List](#get-didcell-list)
* [Get Did Cell List](#get-did-cell-list)
* [Get Account Records Info V2](#get-account-records-info-v2)

* [<em>Deprecated API List</em>](#deprecated-api-list)
Expand Down Expand Up @@ -259,15 +259,15 @@ or json rpc style:
curl -X POST https://indexer-v1.did.id -d '{"jsonrpc": "2.0","id": 1,"method": "das_batchRegisterInfo","params": [{"batch_account": ["xxxxx", "test1.bit", "20230906.bit"]}]}'
```

### Get Did List
### Get Did Cell List

batch get account register info, currently can only check whether the account can be registered
batch get .bit DOBs

**Request**
* host: `indexer-v1.did.id`
* path: `/v1/did/list`
* param:
* support up to max 50 account
* did_type: 0-all DOBs, 1-normal DOBs, 2-recyclable DOBs
```json
{
"type": "blockchain",
Expand All @@ -293,9 +293,7 @@ batch get account register info, currently can only check whether the account ca
"outpoint": "",
"account_id": "",
"account": "",
"args": "",
"expired_at": 0,
"did_cell_status": 1
"expired_at": 0
}
]
}
Expand All @@ -308,6 +306,12 @@ batch get account register info, currently can only check whether the account ca
curl -X POST https://indexer-v1.did.id/v1/did/list -d '{"type": "blockchain","key_info": {"coin_type": "", "key": ""},"page": 1,"size": 10,"did_type": 1}'
```

or json rpc style:

```shell
curl -X POST https://indexer-v1.did.id -d '{"jsonrpc": "2.0","id": 1,"method": "das_didCellList","params": [{"type": "blockchain","key_info": {"coin_type": "", "key": ""},"page": 1,"size": 10,"did_type": 1}]}'
```

### Get Record List

batch get account register info, currently can only check whether the account can be registered
Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module das-account-indexer
go 1.18

require (
github.com/dotbitHQ/das-lib v1.1.1-0.20240708030850-9d23b21d2d0a
github.com/dotbitHQ/das-lib v1.1.1-0.20240708030808-05a81bf44632
github.com/fsnotify/fsnotify v1.5.4
github.com/gin-gonic/gin v1.9.1
github.com/go-redis/redis v6.15.9+incompatible
Expand All @@ -27,8 +27,6 @@ require (
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f // indirect
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce // indirect
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd // indirect
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 // indirect
github.com/bytedance/sonic v1.9.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,11 @@ github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufo
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce h1:YtWJF7RHm2pYCvA5t0RPmAaLUhREsKuKd+SLhxFbFeQ=
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce/go.mod h1:0DVlHczLPewLcPGEIeUEzfOJhqGPQ0mJJRDBtD307+o=
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd h1:R/opQEbFEy9JGkIguV40SvRY1uliPX8ifOvi6ICsFCw=
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg=
github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY=
github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I=
github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc=
github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc=
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 h1:R8vQdOQdZ9Y3SkEwmHoWBmX1DNXhXZqlTpq6s4tyJGc=
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY=
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
Expand Down Expand Up @@ -142,8 +140,8 @@ github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5O
github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/dop251/goja v0.0.0-20211011172007-d99e4b8cbf48/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk=
github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA7c8pLvoGndExHudxTDKZ84Pyvv+90pbBjbTz0Y=
github.com/dotbitHQ/das-lib v1.1.1-0.20240708030850-9d23b21d2d0a h1:ypWzIvgnGQitqE0VTTXrDwDCfpjSBaEpFrX3OZBSGeg=
github.com/dotbitHQ/das-lib v1.1.1-0.20240708030850-9d23b21d2d0a/go.mod h1:XrDous4HH3jze59GLdmdKZaAQ8h3unTFUBsppph7IF8=
github.com/dotbitHQ/das-lib v1.1.1-0.20240708030808-05a81bf44632 h1:mL1cGpU7x8dvC+V9tXfHB9WXCG7DcWE6KANYWB2zOOg=
github.com/dotbitHQ/das-lib v1.1.1-0.20240708030808-05a81bf44632/go.mod h1:WgHO3ZBtA0JY3l5N2gqssPxwvzoRYf4JKpQT6zyLH4s=
github.com/eclipse/paho.mqtt.golang v1.2.0/go.mod h1:H9keYFcgq3Qr5OUJm/JZI/i6U7joQ8SYLhZwfeOo6Ts=
github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819 h1:RIB4cRk+lBqKK3Oy0r2gRX4ui7tuhiZq2SuTtTCi0/0=
Expand Down
1 change: 1 addition & 0 deletions http_server/code/method.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ const (

MethodSubAccountList JsonRpcMethod = "das_subAccountList"
MethodSubAccountVerify JsonRpcMethod = "das_subAccountVerify"
MethodDidCellList JsonRpcMethod = "das_didCellList"
)
9 changes: 4 additions & 5 deletions http_server/handle/account_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package handle

import (
"das-account-indexer/config"
"das-account-indexer/http_server/code"
"das-account-indexer/tables"
"encoding/json"
"fmt"
Expand Down Expand Up @@ -46,7 +45,7 @@ type AccountInfo struct {
DisplayName string `json:"display_name"`
}

func (h *HttpHandle) JsonRpcAccountInfo(p json.RawMessage, apiResp *code.ApiResp) {
func (h *HttpHandle) JsonRpcAccountInfo(p json.RawMessage, apiResp *http_api.ApiResp) {
var req []ReqAccountInfo
err := json.Unmarshal(p, &req)
if err != nil {
Expand All @@ -69,7 +68,7 @@ func (h *HttpHandle) AccountInfo(ctx *gin.Context) {
var (
funcName = "AccountInfo"
req ReqAccountInfo
apiResp code.ApiResp
apiResp http_api.ApiResp
err error
clientIp = GetClientIp(ctx)
)
Expand All @@ -89,7 +88,7 @@ func (h *HttpHandle) AccountInfo(ctx *gin.Context) {
ctx.JSON(http.StatusOK, apiResp)
}

func (h *HttpHandle) doAccountInfo(req *ReqAccountInfo, apiResp *code.ApiResp) error {
func (h *HttpHandle) doAccountInfo(req *ReqAccountInfo, apiResp *http_api.ApiResp) error {
var resp RespAccountInfo

accountId := req.AccountId
Expand Down Expand Up @@ -198,7 +197,7 @@ func (h *HttpHandle) doAccountInfo(req *ReqAccountInfo, apiResp *code.ApiResp) e
return nil
}

func checkAccount(account string, apiResp *code.ApiResp) error {
func checkAccount(account string, apiResp *http_api.ApiResp) error {
if account == "" || !strings.HasSuffix(account, common.DasAccountSuffix) ||
strings.Contains(account, " ") || strings.Contains(account, "_") {
apiResp.ApiRespErr(http_api.ApiCodeAccountFormatInvalid, "account invalid")
Expand Down
7 changes: 3 additions & 4 deletions http_server/handle/account_list.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package handle

import (
"das-account-indexer/http_server/code"
"das-account-indexer/tables"
"encoding/json"
"fmt"
Expand Down Expand Up @@ -32,7 +31,7 @@ type RespAddressAccount struct {
ExpiredAt uint64 `json:"expired_at"`
}

func (h *HttpHandle) JsonRpcAccountList(p json.RawMessage, apiResp *code.ApiResp) {
func (h *HttpHandle) JsonRpcAccountList(p json.RawMessage, apiResp *http_api.ApiResp) {
var req []ReqAccountList
err := json.Unmarshal(p, &req)
if err != nil {
Expand All @@ -55,7 +54,7 @@ func (h *HttpHandle) AccountList(ctx *gin.Context) {
var (
funcName = "AccountList"
req ReqAccountList
apiResp code.ApiResp
apiResp http_api.ApiResp
err error
)

Expand All @@ -74,7 +73,7 @@ func (h *HttpHandle) AccountList(ctx *gin.Context) {
ctx.JSON(http.StatusOK, apiResp)
}

func (h *HttpHandle) doAccountList(req *ReqAccountList, apiResp *code.ApiResp) error {
func (h *HttpHandle) doAccountList(req *ReqAccountList, apiResp *http_api.ApiResp) error {
var resp RespAccountList
resp.AccountList = make([]RespAddressAccount, 0)

Expand Down
7 changes: 3 additions & 4 deletions http_server/handle/account_records.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package handle

import (
"das-account-indexer/http_server/code"
"das-account-indexer/tables"
"encoding/json"
"fmt"
Expand Down Expand Up @@ -29,7 +28,7 @@ type DataRecord struct {
TTL string `json:"ttl"`
}

func (h *HttpHandle) JsonRpcAccountRecords(p json.RawMessage, apiResp *code.ApiResp) {
func (h *HttpHandle) JsonRpcAccountRecords(p json.RawMessage, apiResp *http_api.ApiResp) {
var req []ReqAccountRecords
err := json.Unmarshal(p, &req)
if err != nil {
Expand All @@ -52,7 +51,7 @@ func (h *HttpHandle) AccountRecords(ctx *gin.Context) {
var (
funcName = "AccountRecords"
req ReqAccountRecords
apiResp code.ApiResp
apiResp http_api.ApiResp
err error
clientIp = GetClientIp(ctx)
)
Expand All @@ -74,7 +73,7 @@ func (h *HttpHandle) AccountRecords(ctx *gin.Context) {

type ConvertRecordsFunc func(string) string

func (h *HttpHandle) doAccountRecords(req *ReqAccountRecords, apiResp *code.ApiResp, convertRecordsFunc ConvertRecordsFunc) error {
func (h *HttpHandle) doAccountRecords(req *ReqAccountRecords, apiResp *http_api.ApiResp, convertRecordsFunc ConvertRecordsFunc) error {
var resp RespAccountRecords
resp.Records = make([]DataRecord, 0)

Expand Down
5 changes: 2 additions & 3 deletions http_server/handle/account_records_v2.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package handle

import (
"das-account-indexer/http_server/code"
"encoding/json"
"github.com/dotbitHQ/das-lib/common"
"github.com/dotbitHQ/das-lib/http_api"
Expand All @@ -10,7 +9,7 @@ import (
"net/http"
)

func (h *HttpHandle) JsonRpcAccountRecordsV2(p json.RawMessage, apiResp *code.ApiResp) {
func (h *HttpHandle) JsonRpcAccountRecordsV2(p json.RawMessage, apiResp *http_api.ApiResp) {
var req []ReqAccountRecords
err := json.Unmarshal(p, &req)
if err != nil {
Expand All @@ -33,7 +32,7 @@ func (h *HttpHandle) AccountRecordsV2(ctx *gin.Context) {
var (
funcName = "AccountRecordsV2"
req ReqAccountRecords
apiResp code.ApiResp
apiResp http_api.ApiResp
err error
clientIp = GetClientIp(ctx)
)
Expand Down
7 changes: 3 additions & 4 deletions http_server/handle/account_reverse_address.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package handle

import (
"das-account-indexer/http_server/code"
"encoding/json"
"fmt"
"github.com/dotbitHQ/das-lib/common"
Expand All @@ -24,7 +23,7 @@ type RespAccountReverseAddress struct {
type AccountReverseAddress struct {
}

func (h *HttpHandle) JsonRpcAccountReverseAddress(p json.RawMessage, apiResp *code.ApiResp) {
func (h *HttpHandle) JsonRpcAccountReverseAddress(p json.RawMessage, apiResp *http_api.ApiResp) {
var req []ReqAccountReverseAddress
err := json.Unmarshal(p, &req)
if err != nil {
Expand All @@ -47,7 +46,7 @@ func (h *HttpHandle) AccountReverseAddress(ctx *gin.Context) {
var (
funcName = "AccountReverseAddress"
req ReqAccountReverseAddress
apiResp code.ApiResp
apiResp http_api.ApiResp
err error
)

Expand All @@ -66,7 +65,7 @@ func (h *HttpHandle) AccountReverseAddress(ctx *gin.Context) {
ctx.JSON(http.StatusOK, apiResp)
}

func (h *HttpHandle) doAccountReverseAddress(req *ReqAccountReverseAddress, apiResp *code.ApiResp) error {
func (h *HttpHandle) doAccountReverseAddress(req *ReqAccountReverseAddress, apiResp *http_api.ApiResp) error {
var resp RespAccountReverseAddress
resp.List = make([]core.ChainTypeAddress, 0)

Expand Down
7 changes: 3 additions & 4 deletions http_server/handle/address_account.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package handle

import (
"das-account-indexer/http_server/code"
"encoding/json"
"fmt"
"github.com/dotbitHQ/das-lib/common"
Expand All @@ -17,7 +16,7 @@ type ReqAddressAccount struct {
Address string `json:"address"`
}

func (h *HttpHandle) JsonRpcAddressAccount(p json.RawMessage, apiResp *code.ApiResp) {
func (h *HttpHandle) JsonRpcAddressAccount(p json.RawMessage, apiResp *http_api.ApiResp) {
var req []ReqAddressAccount
err := json.Unmarshal(p, &req)
if err != nil {
Expand Down Expand Up @@ -46,7 +45,7 @@ func (h *HttpHandle) AddressAccount(ctx *gin.Context) {
var (
funcName = "AddressAccount"
req ReqAddressAccount
apiResp code.ApiResp
apiResp http_api.ApiResp
err error
clientIp = GetClientIp(ctx)
)
Expand All @@ -66,7 +65,7 @@ func (h *HttpHandle) AddressAccount(ctx *gin.Context) {
ctx.JSON(http.StatusOK, apiResp)
}

func (h *HttpHandle) doAddressAccount(req *ReqAddressAccount, apiResp *code.ApiResp) error {
func (h *HttpHandle) doAddressAccount(req *ReqAddressAccount, apiResp *http_api.ApiResp) error {
var resp = make([]RespSearchAccount, 0)

addrHex, err := formatAddress(h.DasCore.Daf(), req.Address)
Expand Down
7 changes: 3 additions & 4 deletions http_server/handle/batch_account_records.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package handle

import (
"das-account-indexer/http_server/code"
"das-account-indexer/tables"
"encoding/json"
"fmt"
Expand All @@ -28,7 +27,7 @@ type BatchAccountRecord struct {
ErrMsg string `json:"err_msg"`
}

func (h *HttpHandle) JsonRpcBatchAccountRecords(p json.RawMessage, apiResp *code.ApiResp) {
func (h *HttpHandle) JsonRpcBatchAccountRecords(p json.RawMessage, apiResp *http_api.ApiResp) {
var req []ReqBatchAccountRecords
err := json.Unmarshal(p, &req)
if err != nil {
Expand All @@ -51,7 +50,7 @@ func (h *HttpHandle) BatchAccountRecords(ctx *gin.Context) {
var (
funcName = "BatchAccountRecords"
req ReqBatchAccountRecords
apiResp code.ApiResp
apiResp http_api.ApiResp
err error
)

Expand All @@ -70,7 +69,7 @@ func (h *HttpHandle) BatchAccountRecords(ctx *gin.Context) {
ctx.JSON(http.StatusOK, apiResp)
}

func (h *HttpHandle) doBatchAccountRecords(req *ReqBatchAccountRecords, apiResp *code.ApiResp) error {
func (h *HttpHandle) doBatchAccountRecords(req *ReqBatchAccountRecords, apiResp *http_api.ApiResp) error {
var resp RespBatchAccountRecords
resp.List = make([]BatchAccountRecord, 0)

Expand Down
7 changes: 3 additions & 4 deletions http_server/handle/batch_register_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package handle
import (
"bytes"
"das-account-indexer/config"
"das-account-indexer/http_server/code"
"encoding/binary"
"encoding/json"
"errors"
Expand Down Expand Up @@ -34,7 +33,7 @@ func (h *HttpHandle) BatchRegisterInfo(ctx *gin.Context) {
var (
funcName = "BatchRegisterInfo"
req ReqBatchRegisterInfo
apiResp code.ApiResp
apiResp http_api.ApiResp
err error
)

Expand All @@ -52,7 +51,7 @@ func (h *HttpHandle) BatchRegisterInfo(ctx *gin.Context) {
ctx.JSON(http.StatusOK, apiResp)
}

func (h *HttpHandle) JsonRpcBatchRegisterInfo(p json.RawMessage, apiResp *code.ApiResp) {
func (h *HttpHandle) JsonRpcBatchRegisterInfo(p json.RawMessage, apiResp *http_api.ApiResp) {
var req []ReqBatchRegisterInfo
err := json.Unmarshal(p, &req)
if err != nil {
Expand All @@ -71,7 +70,7 @@ func (h *HttpHandle) JsonRpcBatchRegisterInfo(p json.RawMessage, apiResp *code.A
}
}

func (h *HttpHandle) doBatchRegisterInfo(req *ReqBatchRegisterInfo, apiResp *code.ApiResp) error {
func (h *HttpHandle) doBatchRegisterInfo(req *ReqBatchRegisterInfo, apiResp *http_api.ApiResp) error {
accIds := make([]string, 0, len(req.BatchAccount))
for _, v := range req.BatchAccount {
accIds = append(accIds, common.Bytes2Hex(common.GetAccountIdByAccount(v)))
Expand Down
Loading

0 comments on commit 7a05b22

Please sign in to comment.