Skip to content

Commit

Permalink
add fork height for evm and ont decimals features(#1378)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas7788 authored Oct 28, 2021
1 parent 3b35579 commit e120178
Show file tree
Hide file tree
Showing 11 changed files with 426 additions and 22 deletions.
11 changes: 11 additions & 0 deletions common/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,17 @@ func GetTrackDestroyedContractHeight() uint32 {
}
}

func GetAddDecimalsHeight() uint32 {
switch DefConfig.P2PNode.NetworkId {
case NETWORK_ID_MAIN_NET:
return constants.BLOCKHEIGHT_ADD_DECIMALS_MAINNET
case NETWORK_ID_POLARIS_NET:
return constants.BLOCKHEIGHT_ADD_DECIMALS_POLARIS
default:
return 0
}
}

// the end of unbound timestamp offset from genesis block's timestamp
func GetGovUnboundDeadline() (uint32, uint64) {
count := uint64(0)
Expand Down
3 changes: 3 additions & 0 deletions common/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,6 @@ const BLOCKHEIGHT_NEW_PEER_COST_POLARIS = 13400000

const BLOCKHEIGHT_TRACK_DESTROYED_CONTRACT_MAINNET = 11700000
const BLOCKHEIGHT_TRACK_DESTROYED_CONTRACT_POLARIS = 14100000

const BLOCKHEIGHT_ADD_DECIMALS_MAINNET = 13430000
const BLOCKHEIGHT_ADD_DECIMALS_POLARIS = 0
56 changes: 56 additions & 0 deletions docs/specifications/restful_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ This document describes the restful api format for the http/https used in the On
| [get_networkid](#22-get_networkid) | GET /api/v1/networkid | return the networkid |
| [get_grantong](#23-get_grantong) | GET /api/v1/grantong/:addr | get grant ong |
| [get_syncstatus](#24-get_syncstatus) | GET /api/v1/node/syncstatus |gets the synchronization status of the node |
| [get_balancev2](#25-get_balancev2) | GET /api/v1/balance/:addr | return balance of the account address,ont decimals is 9,ong decimals is 18 |
| [get_allowancev2](#26-get_allowancev2) | GET /api/v1/allowance/:asset/:from/:to | return the allowance from transfer-from accout to transfer-to account, ont decimals is 9,ong decimals is 18 |

### 1 get_conn_count

Expand Down Expand Up @@ -903,6 +905,60 @@ curl -i http://localhost:20334/api/v1/node/syncstatus
}
```


### 25 get_balancev2

return balance of the account address,ont decimals is 9,ong decimals is 18

GET
```
/api/v1/balancev2/:addr
```
> addr: Base58 encoded address
#### Request Example
```
curl -i http://localhost:20334/api/v1/balancev2/TA5uYzLU2vBvvfCMxyV2sdzc9kPqJzGZWq
```

#### Response
```
{
"Action": "getbalancev2",
"Desc": "SUCCESS",
"Error": 0,
"Result": {
"ont": "999999996000000000",
"ong": "999999998000000000000000000",
"height":"1455"
},
"Version": "1.0.0"
}
```

### 26 get_allowancev2

return the allowance from transfer-from accout to transfer-to account, ont decimals is 9,ong decimals is 18

GET
```
/api/v1/allowancev2
```
#### Request Example:
```
curl -i http://localhost:20334/api/v1/allowancev2/:asset/:from/:to
```
#### Response
```
{
"Action": "getallowancev2",
"Desc": "SUCCESS",
"Error": 0,
"Result": "10000000000",
"Version": "1.0.0"
}
```

## Error Code

| Field | Type | Description |
Expand Down
56 changes: 56 additions & 0 deletions docs/specifications/restful_api_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
| [get_networkid](#22-get_networkid) | GET /api/v1/networkid | 得到network id |
| [get_grantong](#23-get_grantong) | GET /api/v1/grantong/:addr | 得到grant ong |
| [get_syncstatus](#24-get_syncstatus) | GET /api/v1/node/syncstatus | 得到节点同步状态 |
| [get_balancev2](#25-get_balancev2) | GET /api/v1/balance/:addr | 得到该地址的账户的余额,ont精度9,ong精度18 |
| [get_allowancev2](#26-get_allowancev2) | GET /api/v1/allowance/:asset/:from/:to | 返回允许从from账户转出到to账户的额度,ont精度9,ong精度18 |

### 1 get_conn_count

Expand Down Expand Up @@ -900,6 +902,60 @@ curl -i http://localhost:20334/api/v1/node/syncstatus
}
```


### 25 get_balancev2

得到该地址的账户的余额。ont精度9,ong精度18

GET
```
/api/v1/balancev2/:addr
```
> addr: Base58编码后的账户地址
#### Request Example
```
curl -i http://localhost:20334/api/v1/balancev2/TA5uYzLU2vBvvfCMxyV2sdzc9kPqJzGZWq
```

#### Response
```
{
"Action": "getbalancev2",
"Desc": "SUCCESS",
"Error": 0,
"Result": {
"ont": "999999996000000000",
"ong": "999999998000000000000000000",
"height":"1455"
},
"Version": "1.0.0"
}
```

### 26 get_allowancev2

得到允许从from账户转出到to账户的额度。ont精度9,ong精度18

GET
```
/api/v1/allowancev2
```
#### Request Example:
```
curl -i http://localhost:20334/api/v1/allowancev2/:asset/:from/:to
```
#### Response
```
{
"Action": "getallowancev2",
"Desc": "SUCCESS",
"Error": 0,
"Result": "10000000000",
"Version": "1.0.0"
}
```

## 错误代码

| Field | Type | Description |
Expand Down
77 changes: 77 additions & 0 deletions docs/specifications/rpc_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ There are some description of parameter used in rpc:
| [getnetworkid](#21-getnetworkid) | | Get the network id | |
| [getgrantong](#22-getgrantong) | | Get grant ong | |
| [getsyncstatus](#23-getsyncstatus) | | Get the synchronization status of the node | |
| [getbalancev2](#24-getbalancev2) | address | return balance of the account address,ont decimals is 9,ong decimals is 18 | |
| [getallowancev2](#25-getallowancev2) | asset, from, to | return the allowance from transfer-from accout to transfer-to account, ont decimals is 9,ong decimals is 18 | |

### 1. getbestblockhash

Expand Down Expand Up @@ -1135,6 +1137,81 @@ Response:
}
```

#### 24. getbalancev2

return balance of the account address,ont decimals is 9,ong decimals is 18

#### 参数定义

address: base58 encoded address

#### Example

Request:

```
{
"jsonrpc": "2.0",
"method": "getbalancev2",
"params": ["TA5uYzLU2vBvvfCMxyV2sdzc9kPqJzGZWq"],
"id": 1
}
```

Response:

```
{
"desc":"SUCCESS",
"error":0,
"id":1,
"jsonrpc":"2.0",
"result":{
"ont": "999999996000000000",
"ong": "999999998000000000000000000",
"height":"1455"
}
}
```


#### 25. getallowancev2

return the allowance from transfer-from accout to transfer-to account, ont decimals is 9,ong decimals is 18

#### 参数定义

asset: "ont" or "ong"

from: transfer out base58 encoded address

to: transfer in base58 encoded address

#### Example

Request:

```
{
"jsonrpc": "2.0",
"method": "getallowancev2",
"params": ["ont","from address","to address"],
"id": 1
}
```

Response:

```
{
"desc":"SUCCESS",
"error":0,
"id":1,
"jsonrpc":"2.0",
"result": "100000000000"
}
```


## Error Code

Expand Down
80 changes: 79 additions & 1 deletion docs/specifications/rpc_api_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
| [getmempooltxstate](#12-getmempooltxstate) | tx_hash | 查询内存中的交易的状态 | |
| [getsmartcodeevent](#13-getsmartcodeevent) | | 得到智能合约执行的结果 | |
| [getblockheightbytxhash](#14-getblockheightbytxhash) | tx_hash | 得到该交易哈希所落账的区块的高度 | |
| [getbalance](#15-getbalance) | address | 返回base58地址的余额 | |
| [getbalance](#15-getbalance) | address | 返回base58地址的余额, ont精度0,ong精度9 | |
| [getmerkleproof](#16-getmerkleproof) | tx_hash | 返回merkle证明 | |
| [getgasprice](#17-getgasprice) | | 返回gas的价格 | |
| [getallowance](#18-getallowance) | asset, from, to | 返回允许从from转出到to账户的额度 | |
Expand All @@ -98,6 +98,8 @@
| [getnetworkid](#21-getnetworkid) | | 获取 network id | |
| [getgrantong](#22-getgrantong) | | 获取 grant ong | |
| [getsyncstatus](#23-getsyncstatus) | | 获取 节点同步的状态 | |
| [getbalancev2](#24-getbalancev2) | address | 返回base58地址的余额, ont精度9, ong精度18 | |
| [getallowancev2](#25-getallowancev2) | asset, from, to | 返回允许从from转出到to账户的额度,ont精度9, ong精度18 | |

### 1. getbestblockhash

Expand Down Expand Up @@ -1147,6 +1149,82 @@ Response:
}
```

#### 24. getbalancev2

返回base58地址的余额, ont精度9, ong精度18

#### 参数定义

address: base58地址

#### Example

Request:

```
{
"jsonrpc": "2.0",
"method": "getbalance",
"params": ["TA5uYzLU2vBvvfCMxyV2sdzc9kPqJzGZWq"],
"id": 1
}
```

Response:

```
{
"desc":"SUCCESS",
"error":0,
"id":1,
"jsonrpc":"2.0",
"result":{
"ont": "999999996000000000",
"ong": "999999998000000000000000000",
"height":"1455"
}
}
```


#### 25. getallowancev2

返回允许从from转出到to账户的额度, ont精度9, ong精度18

#### 参数定义

asset: "ont"或者"ong"

from: 转出账户base58地址

to: 转入账户base58地址

#### Example

Request:

```
{
"jsonrpc": "2.0",
"method": "getallowancev2",
"params": ["ont","from address","to address"],
"id": 1
}
```

Response:

```
{
"desc":"SUCCESS",
"error":0,
"id":1,
"jsonrpc":"2.0",
"result": "100000000000"
}
```


## 错误代码

错误码定义
Expand Down
Loading

0 comments on commit e120178

Please sign in to comment.