Skip to content

Commit

Permalink
json attributes name as 'xxId' or 'id' renamed to 'ID', documentation…
Browse files Browse the repository at this point in the history
… updated and 'chainID' included con tokens of list of tokens
  • Loading branch information
lucasmenendez committed Sep 12, 2023
1 parent e0e3ed9 commit b698563
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 37 deletions.
41 changes: 21 additions & 20 deletions api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ List of already added tokens.
{
"tokens": [
{
"id": "0x1234",
"ID": "0x1234",
"name": "Wrapped Aragon Network Token",
"type": "erc20|erc721|erc777|erc1155|nation3|wANT",
"startBlock": 123456,
"symbol": "wANT",
"tag": "testTag1,testTag2"
"tag": "testTag1,testTag2",
"chainID": 1
}
]
}
Expand Down Expand Up @@ -85,7 +86,7 @@ Triggers a new scan for the provided token, starting from the defined block.

```json
{
"id": "0x1234",
"ID": "0x1234",
"type": "erc20|erc721|erc777|erc1155|nation3|wANT",
"tag": "testTag1,testTag2",
"chainID": 1
Expand All @@ -111,7 +112,7 @@ Returns the information about the token referenced by the provided ID.

```json
{
"id": "0x1324",
"ID": "0x1324",
"type": "erc20",
"decimals": 18,
"startBlock": 123456,
Expand Down Expand Up @@ -154,19 +155,19 @@ Stores a new strategy based on the defined combination of tokens provided, these
{
"tokens": [
{
"id": "0x1324",
"ID": "0x1324",
"name": "wANT",
"minBalance": "10000",
"method": "0x8230"
},
{
"id": "0x5678",
"ID": "0x5678",
"name": "USDC",
"minBalance": "20000",
"method": "0x3241"
},
{
"id": "0x9da2",
"ID": "0x9da2",
"name": "ANT",
"minBalance": "1",
"method": "0x9db1"
Expand All @@ -180,7 +181,7 @@ Stores a new strategy based on the defined combination of tokens provided, these

```json
{
"strategyId": 1
"strategyID": 1
}
```

Expand Down Expand Up @@ -211,7 +212,7 @@ Returns the ID's list of the strategies registered.
| 500 | `error getting strategies information` | 5008 |
| 500 | `error encoding strategies` | 5016 |

### GET `/strategies/{strategyId}`
### GET `/strategies/{strategyID}`
Returns the information of the strategy related to the provided ID.

- 📥 response:
Expand All @@ -221,19 +222,19 @@ Returns the information of the strategy related to the provided ID.
"id": 2,
"tokens": [
{
"id": "0x1324",
"ID": "0x1324",
"name": "wANT",
"minBalance": "10000",
"method": "0x8230"
},
{
"id": "0x5678",
"ID": "0x5678",
"name": "USDC",
"minBalance": "20000",
"method": "0x3241"
},
{
"id": "0x9da2",
"ID": "0x9da2",
"name": "ANT",
"minBalance": "1",
"method": "0x9db1"
Expand Down Expand Up @@ -272,7 +273,7 @@ Returns ID's of the already created strategies including the `tokenAddress` prov
| 500 | `error getting strategies information` | 5008 |
| 500 | `error encoding strategies` | 5016 |

### GET `/census/strategy/{strategyId}`
### GET `/census/strategy/{strategyID}`
Returns a list of censusID for the strategy provided.

- 📥 response:
Expand Down Expand Up @@ -301,7 +302,7 @@ Request the creation of a new census with the strategy provided for the `blockNu

```json
{
"strategyId": 1,
"strategyID": 1,
"blockNumber": 123456,
"anonymous": false
}
Expand All @@ -311,7 +312,7 @@ Request the creation of a new census with the strategy provided for the `blockNu

```json
{
"queueId": "0123456789abcdef0123456789abcdef01234567"
"queueID": "0123456789abcdef0123456789abcdef01234567"
}
```

Expand All @@ -322,19 +323,19 @@ Request the creation of a new census with the strategy provided for the `blockNu
| 400 | `malformed strategy ID, it must be an integer` | 4002 |
| 500 | `error encoding strategy holders` | 5014 |

### GET `/censuses/{censusId}`
### GET `/censuses/{censusID}`
Returns the information of the snapshots related to the provided ID.

- 📥 response:
```json
{
"censusId": 2,
"strategyId": 1,
"censusID": 2,
"strategyID": 1,
"merkleRoot": "e3cb8941e25dcdb36fc21acbe5f6c5a42e0d4f89839ae94952f0ebbd9acd04ac",
"uri": "ipfs://Qma....",
"size": 1000,
"weight": "200000000000000000000",
"chainId": 1,
"chainID": 1,
"anonymous": true
}
```
Expand All @@ -349,7 +350,7 @@ Returns the information of the snapshots related to the provided ID.
| 500 | `error getting census information` | 5009 |
| 500 | `error encoding census` | 5017 |

### GET `/census/queue/{queueId}`
### GET `/census/queue/{queueID}`
Returns the information of the census that are in the creation queue.

- 📥 response:
Expand Down
1 change: 1 addition & 0 deletions api/tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func (capi *census3API) getTokens(msg *api.APIdata, ctx *httprouter.HTTPContext)
StartBlock: uint64(tokenData.CreationBlock.Int32),
Tag: tokenData.Tag.String,
Symbol: tokenData.Symbol.String,
ChainID: int(tokenData.ChainID),
}
tokens.Tokens = append(tokens.Tokens, tokenResponse)
}
Expand Down
14 changes: 7 additions & 7 deletions api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type GetTokenResponse struct {
}

type GetTokensItem struct {
ID string `json:"id"`
ID string `json:"ID"`
Type string `json:"type"`
StartBlock uint64 `json:"startBlock"`
Name string `json:"name"`
Expand All @@ -51,18 +51,18 @@ type TokenHoldersResponse struct {
}

type CreateCensusResquest struct {
StrategyID uint64 `json:"strategyId"`
StrategyID uint64 `json:"strategyID"`
BlockNumber uint64 `json:"blockNumber"`
Anonymous bool `json:"anonymous"`
}

type CreateCensusResponse struct {
QueueID string `json:"queueId"`
QueueID string `json:"queueID"`
}

type GetCensusResponse struct {
CensusID uint64 `json:"censusId"`
StrategyID uint64 `json:"strategyId"`
CensusID uint64 `json:"ID"`
StrategyID uint64 `json:"strategyID"`
MerkleRoot string `json:"merkleRoot"`
URI string `json:"uri"`
Size int32 `json:"size"`
Expand All @@ -79,14 +79,14 @@ type GetStrategiesResponse struct {
}

type GetStrategyToken struct {
ID string `json:"id"`
ID string `json:"ID"`
Name string `json:"name"`
MinBalance string `json:"minBalance"`
Method string `json:"method"`
}

type GetStrategyResponse struct {
ID uint64 `json:"id"`
ID uint64 `json:"ID"`
Tokens []GetStrategyToken `json:"tokens"`
Predicate string `json:"strategy"`
}
Expand Down
20 changes: 10 additions & 10 deletions example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ readonly API_ENDPOINT="127.0.0.1:7788/api"

create_token() {
curl -X POST \
--json "{\"id\": \"$CONTRACT_ADDRESS\",\"type\": \"$CONTRACT_TYPE\",\"chainID\": 1}" \
--json "{\"ID\": \"$CONTRACT_ADDRESS\",\"type\": \"$CONTRACT_TYPE\",\"chainID\": 1}" \
http://$API_ENDPOINT/tokens
}

Expand All @@ -19,7 +19,7 @@ get_token() {

create_census() {
curl -X POST \
--json "{\"strategyId\": $1,\"anonymous\": true}" \
--json "{\"strategyID\": $1,\"anonymous\": true}" \
http://$API_ENDPOINT/censuses
}

Expand All @@ -33,21 +33,21 @@ main() {
echo "-> creating token..."
create_token
# wait to be synced (can be checked getting token info)
echo "-> created, waiting 4m to token scan"
sleep 240
echo "-> created, waiting 2m to token scan"
sleep 120
# get token info after some scan and store the 'defaultStrategy' id.
echo "-> getting token info..."
get_token
# create the census with the token 'defaultStrategy' id and store the
# resulting 'queueId'.
echo "-> enter the strategyId:"
read strategyId
echo "-> enter the strategyID:"
read strategyID
echo "-> creating census..."
create_census $strategyId
echo "-> waiting 1m to census publication"
sleep 60
create_census $strategyID
echo "-> waiting 30s to census publication"
sleep 30
# get the enqueue census creation process with the 'queueId'
echo "-> enter the enqueue census:"
echo "-> enter the enqueue census ID:"
read queueId
get_census $queueId
}
Expand Down

0 comments on commit b698563

Please sign in to comment.