Browse Source

Merge pull request #469 from hermeznetwork/feature/swagger-imprvmnts

Swagger improvements
feature/sql-semaphore1
Eduard S 3 years ago
committed by GitHub
parent
commit
2ae936f2bd
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 59 additions and 85 deletions
  1. +2
    -2
      api/exits_test.go
  2. +55
    -81
      api/swagger.yml
  3. +2
    -2
      db/historydb/views.go

+ 2
- 2
api/exits_test.go

@ -31,9 +31,9 @@ type testExit struct {
EthAddr apitypes.HezEthAddr `json:"hezEthereumAddress"` EthAddr apitypes.HezEthAddr `json:"hezEthereumAddress"`
MerkleProof testCVP `json:"merkleProof"` MerkleProof testCVP `json:"merkleProof"`
Balance string `json:"balance"` Balance string `json:"balance"`
InstantWithdrawn *int64 `json:"instantWithdrawn"`
InstantWithdrawn *int64 `json:"instantWithdraw"`
DelayedWithdrawRequest *int64 `json:"delayedWithdrawRequest"` DelayedWithdrawRequest *int64 `json:"delayedWithdrawRequest"`
DelayedWithdrawn *int64 `json:"delayedWithdrawn"`
DelayedWithdrawn *int64 `json:"delayedWithdraw"`
Token historydb.TokenWithUSD `json:"token"` Token historydb.TokenWithUSD `json:"token"`
} }

+ 55
- 81
api/swagger.yml

@ -64,26 +64,15 @@ servers:
- description: Localhost mock Up - description: Localhost mock Up
url: http://localhost:4010 url: http://localhost:4010
tags: tags:
- name: Account
description: Hermez account and the tokens it holds.
externalDocs:
description: Find out more.
url: 'https://idocs.hermez.io/#/spec/zkrollup/README?id=account-types'
- name: Transaction
description: Send tokens off chain and track transactions.
externalDocs:
description: Find out more
url: 'https://idocs.hermez.io/#/spec/zkrollup/README?id=transaction-types'
- name: Hermez status
description: Info about operators, tokens, auctions and more.
externalDocs:
description: Find out more.
url: 'https://idocs.hermez.io/#/spec/zkrollup/README'
- name: Coordinator
description: Endpoints used by the nodes running in coordinator mode. They are used to interact with the network.
- name: Explorer
description: Endpoints used by the nodes running in explorer mode. They are used to get information of the netwrok.
paths: paths:
'/account-creation-authorization': '/account-creation-authorization':
post: post:
tags: tags:
- Account
- Coordinator
summary: Send an authorization that will allow the coordinator to register accounts associated to an Ethereum address on behalf of the user. summary: Send an authorization that will allow the coordinator to register accounts associated to an Ethereum address on behalf of the user.
description: >- description: >-
Send an authorization to create rollup accounts associated with an Ethereum address. Each account creation (an account can only hold a specific token) is effective once the coordinator forges the corresponding L1CoordinatorTx (which is always of type *account creation*). Send an authorization to create rollup accounts associated with an Ethereum address. Each account creation (an account can only hold a specific token) is effective once the coordinator forges the corresponding L1CoordinatorTx (which is always of type *account creation*).
@ -113,7 +102,7 @@ paths:
'/account-creation-authorization/{hezEthereumAddress}': '/account-creation-authorization/{hezEthereumAddress}':
get: get:
tags: tags:
- Account
- Coordinator
summary: Find out if the coordinator has the ability to create accounts associated with an Ethereum address. summary: Find out if the coordinator has the ability to create accounts associated with an Ethereum address.
description: >- description: >-
Returns the authorization to perform an account creation with the given Ethereum address on behalf of the Ethereum address holder. Returns the authorization to perform an account creation with the given Ethereum address on behalf of the Ethereum address holder.
@ -153,7 +142,7 @@ paths:
'/accounts': '/accounts':
get: get:
tags: tags:
- Account
- Explorer
summary: Get accounts balances and other associated information. summary: Get accounts balances and other associated information.
description: Get account balances and other associated information. description: Get account balances and other associated information.
operationId: getAccounts operationId: getAccounts
@ -166,7 +155,7 @@ paths:
$ref: '#/components/schemas/HezEthereumAddress' $ref: '#/components/schemas/HezEthereumAddress'
- name: BJJ - name: BJJ
in: query in: query
description: Only get accounts associated to a BabyJubJub public key. Incompatible with the query `hezEthereumAddress`.
description: Only get accounts associated to a BabyJubJub compressed public key. Incompatible with the query `hezEthereumAddress`.
required: false required: false
schema: schema:
$ref: '#/components/schemas/BJJ' $ref: '#/components/schemas/BJJ'
@ -224,7 +213,7 @@ paths:
'/accounts/{accountIndex}': '/accounts/{accountIndex}':
get: get:
tags: tags:
- Account
- Explorer
summary: Get an account by its index. summary: Get an account by its index.
description: Get an account by its index. description: Get an account by its index.
operationId: getAccount operationId: getAccount
@ -263,7 +252,7 @@ paths:
'/exits': '/exits':
get: get:
tags: tags:
- Account
- Explorer
summary: Get exit information. This information is required to perform a withdraw. summary: Get exit information. This information is required to perform a withdraw.
description: Get exit information. This information is required to perform a withdraw. description: Get exit information. This information is required to perform a withdraw.
operationId: getExits operationId: getExits
@ -282,7 +271,7 @@ paths:
$ref: '#/components/schemas/HezEthereumAddress' $ref: '#/components/schemas/HezEthereumAddress'
- name: BJJ - name: BJJ
in: query in: query
description: Get exits associated to a BabyJubJub public key. Incompatible with query `hezEthereumAddress` and `accountIndex`.
description: Get exits associated to a BabyJubJub compressed public key. Incompatible with query `hezEthereumAddress` and `accountIndex`.
required: false required: false
schema: schema:
$ref: '#/components/schemas/BJJ' $ref: '#/components/schemas/BJJ'
@ -350,7 +339,7 @@ paths:
'/exits/{batchNum}/{accountIndex}': '/exits/{batchNum}/{accountIndex}':
get: get:
tags: tags:
- Account
- Explorer
summary: Get specific exit information. summary: Get specific exit information.
description: Get exit information form a specific exit tree and account. This information is required to perform a withdraw. Exits are identified with accounIndex and batchNum since every batch that has exits has a different exit tree. description: Get exit information form a specific exit tree and account. This information is required to perform a withdraw. Exits are identified with accounIndex and batchNum since every batch that has exits has a different exit tree.
operationId: getExit operationId: getExit
@ -395,7 +384,7 @@ paths:
'/transactions-pool': '/transactions-pool':
post: post:
tags: tags:
- Transaction
- Coordinator
summary: Add an L2 transaction to the coordinator's pool. summary: Add an L2 transaction to the coordinator's pool.
description: >- description: >-
Send L2 transaction. The transaction will be stored in the transaction pool of the coordinator and eventually forged. Send L2 transaction. The transaction will be stored in the transaction pool of the coordinator and eventually forged.
@ -429,7 +418,7 @@ paths:
'/transactions-pool/{id}': '/transactions-pool/{id}':
get: get:
tags: tags:
- Transaction
- Coordinator
summary: Get details and status of a transaction that is in the pool. summary: Get details and status of a transaction that is in the pool.
description: >- description: >-
Get transaction from the pool by its ID. This endpoint is specially useful for tracking the status of a transaction that may not be forged yet. Get transaction from the pool by its ID. This endpoint is specially useful for tracking the status of a transaction that may not be forged yet.
@ -472,7 +461,7 @@ paths:
'/transactions-history': '/transactions-history':
get: get:
tags: tags:
- Transaction
- Explorer
summary: Get details and status of transactions that have been forged. summary: Get details and status of transactions that have been forged.
description: >- description: >-
Get historical transactions. This endpoint will return all the different types of **forged** transactions, this means that: Get historical transactions. This endpoint will return all the different types of **forged** transactions, this means that:
@ -494,7 +483,7 @@ paths:
$ref: '#/components/schemas/HezEthereumAddress' $ref: '#/components/schemas/HezEthereumAddress'
- name: BJJ - name: BJJ
in: query in: query
description: Only get transactions associated with a BabyJubJub public key. Incompatible with the queries `hezEthereumAddress` and `accountIndex`.
description: Only get transactions associated with a BabyJubJub compressed public key. Incompatible with the queries `hezEthereumAddress` and `accountIndex`.
required: false required: false
schema: schema:
$ref: '#/components/schemas/BJJ' $ref: '#/components/schemas/BJJ'
@ -562,7 +551,7 @@ paths:
'/transactions-history/{id}': '/transactions-history/{id}':
get: get:
tags: tags:
- Transaction
- Explorer
summary: Get details and status of a historical transaction. summary: Get details and status of a historical transaction.
description: >- description: >-
Get transaction by its ID. This endpoint will return all the different types of transactions except those that are still in the pool of any coordinator. Get transaction by its ID. This endpoint will return all the different types of transactions except those that are still in the pool of any coordinator.
@ -602,7 +591,7 @@ paths:
'/batches': '/batches':
get: get:
tags: tags:
- Hermez status
- Explorer
summary: Get information about forged batches. summary: Get information about forged batches.
description: >- description: >-
Get information about forged batches. Get information about forged batches.
@ -678,7 +667,7 @@ paths:
'/batches/{batchNum}': '/batches/{batchNum}':
get: get:
tags: tags:
- Hermez status
- Explorer
summary: Get a specific batch. summary: Get a specific batch.
description: >- description: >-
Get a specific batch. Get a specific batch.
@ -718,7 +707,7 @@ paths:
'/full-batches/{batchNum}': '/full-batches/{batchNum}':
get: get:
tags: tags:
- Hermez status
- Explorer
summary: Get a full batch. summary: Get a full batch.
description: >- description: >-
Get a specific batch, including the associated transactions. The object returned in this method can be a bit heavy. Get a specific batch, including the associated transactions. The object returned in this method can be a bit heavy.
@ -759,7 +748,7 @@ paths:
'/slots': '/slots':
get: get:
tags: tags:
- Hermez status
- Explorer
summary: Get information about slots. summary: Get information about slots.
description: >- description: >-
Get information about slots. Get information about slots.
@ -835,7 +824,7 @@ paths:
'/slots/{slotNum}': '/slots/{slotNum}':
get: get:
tags: tags:
- Hermez status
- Explorer
summary: Get information about a specific slot. summary: Get information about a specific slot.
description: >- description: >-
Get information about a specific slot. Get information about a specific slot.
@ -875,7 +864,7 @@ paths:
'/bids': '/bids':
get: get:
tags: tags:
- Hermez status
- Explorer
summary: Get a list of bids. summary: Get a list of bids.
description: >- description: >-
Get a list of bids. It's necessary to provide at least one of the following filters: `slotNum`, `bidderAddr`. Get a list of bids. It's necessary to provide at least one of the following filters: `slotNum`, `bidderAddr`.
@ -939,7 +928,7 @@ paths:
'/state': '/state':
get: get:
tags: tags:
- Hermez status
- Explorer
summary: Return information that represents the current state of the network. summary: Return information that represents the current state of the network.
description: Return information that represents the current state of the network. It also includes metrics and statistics. description: Return information that represents the current state of the network. It also includes metrics and statistics.
operationId: getState operationId: getState
@ -965,7 +954,7 @@ paths:
'/config': '/config':
get: get:
tags: tags:
- Hermez status
- Explorer
summary: Return constant configuration of the network. summary: Return constant configuration of the network.
description: Return constant configuration of the network. description: Return constant configuration of the network.
operationId: getConfig operationId: getConfig
@ -985,7 +974,7 @@ paths:
'/tokens': '/tokens':
get: get:
tags: tags:
- Hermez status
- Explorer
summary: Get information of the supported tokens in the Hermez Network. summary: Get information of the supported tokens in the Hermez Network.
description: Get information of the supported tokens in the Hermez Network. description: Get information of the supported tokens in the Hermez Network.
operationId: getTokens operationId: getTokens
@ -1058,7 +1047,7 @@ paths:
'/tokens/{id}': '/tokens/{id}':
get: get:
tags: tags:
- Hermez status
- Explorer
summary: Get information of a token supported by Hermez Network. summary: Get information of a token supported by Hermez Network.
description: Get information of a token supported by Hermez Network. description: Get information of a token supported by Hermez Network.
operationId: getToken operationId: getToken
@ -1097,7 +1086,7 @@ paths:
'/coordinators': '/coordinators':
get: get:
tags: tags:
- Hermez status
- Explorer
summary: Get information about coordinators. summary: Get information about coordinators.
description: Get information about coordinators. description: Get information about coordinators.
operationId: getCoordinators operationId: getCoordinators
@ -1191,7 +1180,7 @@ components:
toBjj: toBjj:
type: string type: string
description: >- description: >-
BabyJubJub public key, encoded as base64 URL (RFC 4648), which result in 33 bytes. The padding byte is replaced by a sum of the encoded bytes.
BabyJubJub compressed public key, encoded as base64 URL (RFC 4648), which result in 33 bytes. The padding byte is replaced by a sum of the encoded bytes.
If this is provided, toAccountIndex must be null and toHezEthereumAddress must be hez:0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF. If this is provided, toAccountIndex must be null and toHezEthereumAddress must be hez:0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF.
pattern: "^hez:[A-Za-z0-9_-]{44}$" pattern: "^hez:[A-Za-z0-9_-]{44}$"
example: null example: null
@ -1291,7 +1280,7 @@ components:
nullable: true nullable: true
fromBJJ: fromBJJ:
type: string type: string
description: "BabyJubJub public key, encoded as base64 URL (RFC 4648), which result in 33 bytes. The padding byte is replaced by a sum of the encoded bytes."
description: "BabyJubJub compressed public key, encoded as base64 URL (RFC 4648), which result in 33 bytes. The padding byte is replaced by a sum of the encoded bytes."
pattern: "^hez:[A-Za-z0-9_-]{44}$" pattern: "^hez:[A-Za-z0-9_-]{44}$"
example: "hez:9CK9fjQdMUTGm8KDvGLy3MB-vnP0NCcGX7Uh7OO6KRJm" example: "hez:9CK9fjQdMUTGm8KDvGLy3MB-vnP0NCcGX7Uh7OO6KRJm"
nullable: true nullable: true
@ -1310,7 +1299,7 @@ components:
nullable: true nullable: true
toBjj: toBjj:
type: string type: string
description: "BabyJubJub public key, encoded as base64 URL (RFC 4648), which result in 33 bytes. The padding byte is replaced by a sum of the encoded bytes."
description: "BabyJubJub compressed public key, encoded as base64 URL (RFC 4648), which result in 33 bytes. The padding byte is replaced by a sum of the encoded bytes."
pattern: "^hez:[A-Za-z0-9_-]{44}$" pattern: "^hez:[A-Za-z0-9_-]{44}$"
example: null example: null
nullable: true nullable: true
@ -1363,7 +1352,7 @@ components:
example: null example: null
requestToBJJ: requestToBJJ:
type: string type: string
description: "BabyJubJub public key, encoded as base64 URL (RFC 4648), which result in 33 bytes. The padding byte is replaced by a sum of the encoded bytes."
description: "BabyJubJub compressed public key, encoded as base64 URL (RFC 4648), which result in 33 bytes. The padding byte is replaced by a sum of the encoded bytes."
pattern: "^hez:[A-Za-z0-9_-]{44}$" pattern: "^hez:[A-Za-z0-9_-]{44}$"
nullable: true nullable: true
example: null example: null
@ -1468,7 +1457,7 @@ components:
example: "hez:0xaa942cfcd25ad4d90a62358b0dd84f33b398262a" example: "hez:0xaa942cfcd25ad4d90a62358b0dd84f33b398262a"
BJJ: BJJ:
type: string type: string
description: "BabyJubJub public key, encoded as base64 URL (RFC 4648), which result in 33 bytes. The padding byte is replaced by a sum of the encoded bytes."
description: "BabyJubJub compressed public key, encoded as base64 URL (RFC 4648), which result in 33 bytes. The padding byte is replaced by a sum of the encoded bytes."
pattern: "^hez:[A-Za-z0-9_-]{44}$" pattern: "^hez:[A-Za-z0-9_-]{44}$"
example: "hez:rR7LXKal-av7I56Y0dEBCVmwc9zpoLY5ERhy5w7G-xwe" example: "hez:rR7LXKal-av7I56Y0dEBCVmwc9zpoLY5ERhy5w7G-xwe"
AccountIndex: AccountIndex:
@ -1623,7 +1612,7 @@ components:
nullable: true nullable: true
fromBJJ: fromBJJ:
type: string type: string
description: "BabyJubJub public key, encoded as base64 URL (RFC 4648), which result in 33 bytes. The padding byte is replaced by a sum of the encoded bytes."
description: "BabyJubJub compressed public key, encoded as base64 URL (RFC 4648), which result in 33 bytes. The padding byte is replaced by a sum of the encoded bytes."
pattern: "^hez:[A-Za-z0-9_-]{44}$" pattern: "^hez:[A-Za-z0-9_-]{44}$"
example: "hez:9CK9fjQdMUTGm8KDvGLy3MB-vnP0NCcGX7Uh7OO6KRJm" example: "hez:9CK9fjQdMUTGm8KDvGLy3MB-vnP0NCcGX7Uh7OO6KRJm"
nullable: true nullable: true
@ -1639,7 +1628,7 @@ components:
nullable: true nullable: true
toBJJ: toBJJ:
type: string type: string
description: "BabyJubJub public key, encoded as base64 URL (RFC 4648), which result in 33 bytes. The padding byte is replaced by a sum of the encoded bytes."
description: "BabyJubJub compressed public key, encoded as base64 URL (RFC 4648), which result in 33 bytes. The padding byte is replaced by a sum of the encoded bytes."
pattern: "^hez:[A-Za-z0-9_-]{44}$" pattern: "^hez:[A-Za-z0-9_-]{44}$"
example: "hez:f1J78_6uqTyjX6jrVCqN4RFeRBnWQAGl477ZFtOnH6Sm" example: "hez:f1J78_6uqTyjX6jrVCqN4RFeRBnWQAGl477ZFtOnH6Sm"
nullable: true nullable: true
@ -1981,7 +1970,7 @@ components:
URL: URL:
type: string type: string
description: HTTP URL description: HTTP URL
example: "https://hermez.io"
example: "https://apimock.hermez.network"
TokenSymbol: TokenSymbol:
type: string type: string
description: Abreviation of the token name. description: Abreviation of the token name.
@ -2318,7 +2307,7 @@ components:
additionalProperties: false additionalProperties: false
balance: balance:
$ref: '#/components/schemas/BigInt' $ref: '#/components/schemas/BigInt'
instantWithdrawn:
instantWithdraw:
type: integer type: integer
description: Block in which the exit balance was instantly withdrawn. Null indicates that an instant withdrawn hasn't been performed. description: Block in which the exit balance was instantly withdrawn. Null indicates that an instant withdrawn hasn't been performed.
minimum: 0 minimum: 0
@ -2332,7 +2321,7 @@ components:
maximum: 1.84467440737096e+19 maximum: 1.84467440737096e+19
example: null example: null
nullable: true nullable: true
delayedWithdrawn:
delayedWithdraw:
type: integer type: integer
description: Block in which the exit balance was delayed withdrawn after a delay withdraw request. Null indicates that a delay withdraw hasn't been performed. description: Block in which the exit balance was delayed withdrawn after a delay withdraw request. Null indicates that a delay withdraw hasn't been performed.
minimum: 0 minimum: 0
@ -2349,9 +2338,9 @@ components:
- itemId - itemId
- merkleProof - merkleProof
- balance - balance
- instantWithdrawn
- instantWithdraw
- delayedWithdrawRequest - delayedWithdrawRequest
- delayedWithdrawn
- delayedWithdraw
- token - token
additionalProperties: false additionalProperties: false
Exits: Exits:
@ -2387,37 +2376,22 @@ components:
token: token:
$ref: '#/components/schemas/Token' $ref: '#/components/schemas/Token'
example: example:
exits:
- accountIndex: hez:ETH:259
balance: '66666600000000000'
batchNum: 8
delayedWithdrawRequest:
delayedWithdrawn:
instantWithdrawn:
accountIndex: hez:ETH:259
balance: '2590000000000000000'
bjj: hez:W6x4TZOAZ9mAqdOb3Xm_hKDLspaXfEfMMN4tXOkinS-W
hezEthereumAddress: hez:0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf
itemId: 4
nonce: 0
token:
USD: 500
decimals: 18
ethereumAddress: '0x0000000000000000000000000000000000000000'
ethereumBlockNum: 0
fiatUpdate: '2020-11-26T09:53:47.444444Z'
id: 0
itemId: 1 itemId: 1
merkleProof:
Fnc: 0
IsOld0: true
Key: '256'
OldKey: '256'
OldValue: '256'
Root: '256'
Siblings:
- '0'
- '1'
- '2'
Value: '256'
token:
USD: 500
decimals: 18
ethereumAddress: '0x0000000000000000000000000000000000000000'
ethereumBlockNum: 0
fiatUpdate: '2020-11-26T09:57:29.110879Z'
id: 0
itemId: 1
name: Ether
symbol: ETH
pendingItems: 0
name: Ether
symbol: ETH
additionalProperties: false additionalProperties: false
required: required:
- itemId - itemId

+ 2
- 2
db/historydb/views.go

@ -200,9 +200,9 @@ func (e ExitAPI) MarshalJSON() ([]byte, error) {
"hezEthereumAddress": e.EthAddr, "hezEthereumAddress": e.EthAddr,
"merkleProof": e.MerkleProof, "merkleProof": e.MerkleProof,
"balance": e.Balance, "balance": e.Balance,
"instantWithdrawn": e.InstantWithdrawn,
"instantWithdraw": e.InstantWithdrawn,
"delayedWithdrawRequest": e.DelayedWithdrawRequest, "delayedWithdrawRequest": e.DelayedWithdrawRequest,
"delayedWithdrawn": e.DelayedWithdrawn,
"delayedWithdraw": e.DelayedWithdrawn,
"token": map[string]interface{}{ "token": map[string]interface{}{
"id": e.TokenID, "id": e.TokenID,
"itemId": e.TokenItemID, "itemId": e.TokenItemID,

Loading…
Cancel
Save