Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dutch_auction'
Browse files Browse the repository at this point in the history
# Conflicts:
#	go.mod
#	go.sum
  • Loading branch information
457813723 committed Nov 23, 2023
2 parents 84d7b21 + e38d891 commit e8235d6
Show file tree
Hide file tree
Showing 27 changed files with 1,368 additions and 44 deletions.
259 changes: 257 additions & 2 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
* [Account Order Detail](#account-order-detail)
* [Address Deposit](#address-deposit)
* [Character Set List](#character-set-list)
* [Account Auction Info](#account-auction-info)
* [Account Auction Price](#account-auction-price)
* [Account Auction OrderStatus](#account-auction-order_status)
* [Account Auction PendingOrders](#account-auction-pending_orders)
* [OPERATE API LIST](#operate-api-list)
* [Reverse Declare (Deprecated)](#reverse-declare)
* [Reverse Redeclare (Deprecated)](#reverse-redeclare)
Expand All @@ -35,6 +39,7 @@
* [Account Order Pay Hash](#account-order-pay-hash)
* [Account Register](#account-register)
* [Account Renew](#account-renew)
* [Account Auction Bid](#account-auction-bid)
* [NODE RPC](#node-rpc)
* [Node Ckb Rpc](#node-ckb-rpc)

Expand Down Expand Up @@ -313,7 +318,9 @@ curl -X POST http://127.0.0.1:8120/v1/account/mine -d'{"chain_type":1,"address":
* 13: unregisterable
* 14: sub-account
* 15: cross-chain

* 17: on dutch auction period
* 18: on dutch auction deliver period
* re_registered_time: Time for re registration
```json
{
"err_no": 0,
Expand All @@ -333,7 +340,8 @@ curl -X POST http://127.0.0.1:8120/v1/account/mine -d'{"chain_type":1,"address":
"base_amount": "3.89",
"confirm_proposal_hash": "0xec7bec47a4d3ad467253925a7e097f311e0738d625d55f8b3420cabaaa9b5201",
"premium_percentage": "",// for stripe usd premium
"premium_base": "" // for stripe usd premium
"premium_base": "", // for stripe usd premium
"re_registered_time": 1672211096
}
}
```
Expand Down Expand Up @@ -1935,3 +1943,250 @@ curl -X POST http://127.0.0.1:8119/v1/account/renew -d'{"chain_type":1,"address"
curl -X POST http://127.0.0.1:8120/v1/node/ckb/rpc -d'{"jsonrpc":"2.0","id":2976777,"method":"get_blockchain_info","params":[]}'
```


#### Account Auction Info

**Request**

* path: /account/auction/info
* get dutch auction info of a account
* param:

```json
{
"account":"michaeltest1.bit",
"type":"blockchain",
"key_info":{
"coin_type":"60",
"key":"0xd437b8e9cA16Fce24bF3258760c3567214213C5A"
}
}
```

**Response**

```json
{
"err_no": 0,
"err_msg": "",
"data": {
"account_id": "",
"account": "",
"bid_status": 2,
"hash": "",
"start_auction_time": 0,
"end_auction_time": 0,
"expired_at": 0,
"account_price": "5",
"base_amount": "0.82"
}
}
```

**Usage**

```curl
curl --location 'http://127.0.0.1:8120/v1/account/auction/info' \
--header 'Content-Type: application/json' \
--data '{
"account":"michaeltest1.bit",
"type":"blockchain",
"key_info":{
"coin_type":"60",
"key":"0xd437b8e9cA16Fce24bF3258760c3567214213C5A"
}
}'
```


#### Account Auction Price

**Request**

* path: /account/auction/price
* get dutch auction price of a account
* param:

```json
{
"account":"michaeltest1.bit"
}
```

**Response**

```json
{
"err_no": 0,
"err_msg": "",
"data": {
"account_price": "5",
"base_amount": "0.82",
"premium_price": 20
}
}
```

**Usage**

```curl
curl --location 'http://127.0.0.1:8120/v1/account/auction/price' \
--header 'Content-Type: application/json' \
--data '{
"account":"michaeltest1.bit"
}'
```

#### Account Auction OrderStatus

**Request**

* path: /account/auction/order-status
* get status of a dutch auction order
* param:

```json
{
"account":"michaeltest1.bit",
"hash": "0xb9e094dd6fcaa6c68d44233cb5331e63bd966fa86659fc45d30089336021f26e",
"type":"blockchain",
"key_info":{
"coin_type":"60",
"key":"0xd437b8e9cA16Fce24bF3258760c3567214213C5A"
}
}
```

**Response**

```json
{
"err_no": 0,
"err_msg": "",
"data": {
"account": "michaeltest1.bit",
"hash": "0xeb4871b7af2ca7129a43c5991c408148abd195eb5699223fad11a712b1e1d584",
"status": 0,
"basic_price": "6",
"premium_price": "100"
}
}
```

**Usage**

```curl
curl --location 'http://127.0.0.1:8120/v1/account/auction/order-status' \
--header 'Content-Type: application/json' \
--data '{
"account":"michaeltest1.bit",
"type":"blockchain",
"key_info":{
"coin_type":"60",
"key":"0xd437b8e9cA16Fce24bF3258760c3567214213C5A"
}
}'
```

#### Account Auction PendingOrders

**Request**

* path: /account/auction/pending-order
* get dutch auction order with pending status
* param:

```json
{
"type":"blockchain",
"key_info":{
"coin_type":"60",
"key":"0xd437b8e9cA16Fce24bF3258760c3567214213C5A"
}
}
```

**Response**

```json
{
"err_no": 0,
"err_msg": "",
"data": [
{
"account": "michaeltest1.bit",
"outpoint": "0xeb4871b7af2ca7129a43c5991c408148abd195eb5699223fad11a712b1e1d584-0",
"status": 0,
"basic_price": "6",
"premium_price": "100"
}
]
}
```

**Usage**

```curl
curl --location 'http://127.0.0.1:8120/v1/account/auction/pending-order' \
--header 'Content-Type: application/json' \
--data '{
"type":"blockchain",
"key_info":{
"coin_type":"60",
"key":"0xd437b8e9cA16Fce24bF3258760c3567214213C5A"
}
}'
```

#### Account Auction Bid

**Request**

* path: /account/auction/bid
* bid a account during dutch auction period
* param:

```json
{
"account":"michaeltest1.bit",
"type":"blockchain",
"key_info":{
"coin_type":"60",
"key":"0xd437b8e9cA16Fce24bF3258760c3567214213C5A"
}
}
```

**Response**

```json
{
"err_no": 0,
"err_msg": "",
"data": {
"sign_key": "",
"sign_list": [
{
"sign_type": 5,
"sign_msg": ""
}
],
"mm_json": {}
}
}
```

**Usage**

```curl
curl --location 'http://127.0.0.1:8120/v1/account/auction/bid' \
--header 'Content-Type: application/json' \
--data '{
"account":"michaeltest1.bit",
"type":"blockchain",
"key_info":{
"coin_type":"60",
"key":"0xd437b8e9cA16Fce24bF3258760c3567214213C5A"
}
}'
```
23 changes: 23 additions & 0 deletions block_parser/action_dutch_auction.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package block_parser

import (
"fmt"
"github.com/dotbitHQ/das-lib/common"
)

func (b *BlockParser) ActionBidExpiredAccountAuction(req FuncTransactionHandleReq) (resp FuncTransactionHandleResp) {
if isCV, err := isCurrentVersionTx(req.Tx, common.DasContractNameAccountCellType); err != nil {
resp.Err = fmt.Errorf("isCurrentVersion err: %s", err.Error())
return
} else if !isCV {
return
}

outpoint := common.OutPoint2String(req.TxHash, 0)
if err := b.DbDao.UpdatePendingStatusToConfirm(req.Action, outpoint, req.BlockNumber, req.BlockTimestamp); err != nil {
resp.Err = fmt.Errorf("UpdatePendingStatusToConfirm err: %s", err.Error())
return
}

return
}
1 change: 1 addition & 0 deletions block_parser/block_parser_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func (b *BlockParser) registerTransactionHandle() {
b.mapTransactionHandle[common.DasActionEditRecords] = b.ActionEditRecords
b.mapTransactionHandle[common.DasActionEditManager] = b.ActionEditManager
b.mapTransactionHandle[common.DasActionTransferAccount] = b.ActionTransferAccount
b.mapTransactionHandle[common.DasActionBidExpiredAccountAuction] = b.ActionBidExpiredAccountAuction
//
//b.mapTransactionHandle[common.DasActionDeclareReverseRecord] = b.ActionDeclareReverseRecord
//b.mapTransactionHandle[common.DasActionRedeclareReverseRecord] = b.ActionRedeclareReverseRecord
Expand Down
3 changes: 2 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ func runServer(ctx *cli.Context) error {
DasCore: dasCore,
DasCache: dasCache,
TxBuilderBase: txBuilderBase,
ServerScript: serverScript,
MapReservedAccounts: builderConfigCell.ConfigCellPreservedAccountMap,
MapUnAvailableAccounts: builderConfigCell.ConfigCellUnavailableAccountMap,
})
Expand Down Expand Up @@ -250,7 +251,7 @@ func initDasCore() (*core.DasCore, *dascache.DasCache, error) {
common.DasContractNameBalanceCellType, common.DasContractNameDispatchCellType, common.DasContractNameApplyRegisterCellType,
common.DasContractNamePreAccountCellType, common.DasContractNameProposalCellType, common.DasContractNameReverseRecordCellType,
common.DasContractNameIncomeCellType, common.DasContractNameAlwaysSuccess, common.DASContractNameEip712LibCellType,
common.DASContractNameSubAccountCellType, common.DasKeyListCellType)
common.DASContractNameSubAccountCellType, common.DasKeyListCellType, common.DasContractNameDpCellType)
ops := []core.DasCoreOption{
core.WithClient(ckbClient),
core.WithDasContractArgs(env.ContractArgs),
Expand Down
10 changes: 10 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ type CfgServer struct {
UniPayRefundSwitch bool `json:"uni_pay_refund_switch" yaml:"uni_pay_refund_switch"`
HedgeUrl string `json:"hedge_url" yaml:"hedge_url"`
PrometheusPushGateway string `json:"prometheus_push_gateway" yaml:"prometheus_push_gateway"`
// ConfigCellDPoint.transfer_whitelist
TransferWhitelist string `json:"transfer_whitelist" yaml:"transfer_whitelist"`
TransferWhitelistPrivate string `json:"transfer_whitelist_private" yaml:"transfer_whitelist_private"`
//ConfigCellDPoint.capacity_recycle_whitelist
CapacityWhitelist string `json:"capacity_whitelist" yaml:"capacity_whitelist"`
CapacityWhitelistPrivate string `json:"capacity_whitelist_private" yaml:"capacity_whitelist_private"`
SplitCount int `json:"split_count" yaml:"split_count"`
SplitAmount uint64 `json:"split_amount" yaml:"split_amount"`
} `json:"server" yaml:"server"`
Origins []string `json:"origins" yaml:"origins"`
InviterWhitelist map[string]string `json:"inviter_whitelist" yaml:"inviter_whitelist"`
Expand Down Expand Up @@ -146,6 +154,8 @@ func GetUnipayAddress(tokenId tables.PayTokenId) string {
return Cfg.PayAddressMap["doge"]
case tables.TokenIdStripeUSD:
return "stripe"
case tables.ToKenIdDidPoint:
return Cfg.PayAddressMap["did_point"]
}
log.Error("GetUnipayAddress not supported:", tokenId)
return ""
Expand Down
1 change: 1 addition & 0 deletions dao/dao.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func NewGormDB(dbMysql, parserMysql config.DbMysql) (*DbDao, error) {
&tables.TableDasOrderTxInfo{},
&tables.TableRegisterPendingInfo{},
&tables.TableCoupon{},
&tables.TableAuctionOrder{},
); err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit e8235d6

Please sign in to comment.