Skip to content

Commit

Permalink
Describe api in api blueprint
Browse files Browse the repository at this point in the history
  • Loading branch information
perekopskiy committed Jun 1, 2021
1 parent b20307c commit 41ac552
Show file tree
Hide file tree
Showing 23 changed files with 1,362 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/tests/apiary/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tmp
index.html

1 change: 1 addition & 0 deletions core/tests/apiary/compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
aglio -i input.apib -o index.html
32 changes: 32 additions & 0 deletions core/tests/apiary/dredd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
color: true
dry-run: null
hookfiles: null
language: nodejs
require: null
server: null
server-wait: 10
init: false
custom: {}
names: false
only: []
reporter: []
output: []
header: []
sorted: false
user: null
inline-errors: false
details: false
method: []
loglevel: warning
path: []
hooks-worker-timeout: 5000
hooks-worker-connect-timeout: 1500
hooks-worker-connect-retry: 500
hooks-worker-after-connect-wait: 100
hooks-worker-term-timeout: 5000
hooks-worker-term-retry: 500
hooks-worker-handler-host: 127.0.0.1
hooks-worker-handler-port: 61321
config: ./dredd.yml
blueprint: ./input2.apib
endpoint: 'http://127.0.0.1:3001/api/v0.2'
58 changes: 58 additions & 0 deletions core/tests/apiary/groups/accounts.apib
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Group Accounts

## api/v0.2/accounts [/accounts/{accountIdOrAddress}/{stateType}]

+ Parameters
+ accountIdOrAddress (required, string, `2319`) ... Account Id or address in the zkSync network
+ stateType (required, "committed" | "finalized", `committed`) ... The type of account state which we want to get

### Get account state [GET]
Returns the account state for a particular block

+ Response 200 (application/json)
+ Attributes
+ request (Request, required)
+ status: success (string, required)
+ result (Account, required, nullable)
+ error (Error, required, nullable)

## api/v0.2/accounts/{account_id}/transactions [/accounts/{accountIdOrAddress}/transactions{?from,limit,direction}]

+ Parameters
+ accountIdOrAddress (required, string, `2319`) ... Account Id or address in the zkSync network
+ from (required, "latest" | string, `latest`) ... From which transaction to show
+ limit (required, number, `2`) ... The limit of transactions to be shown
+ direction (required, "newer" | "older", `older`) ... newer or older than the id of the `from`


### Get account transactions [GET]
Returns the transactions for a particular account according to the query params

+ Response 200 (application/json)
+ Attributes
+ request (Request, required)
+ status: success (string, required)
+ result (object, required, nullable)
+ pagination (PaginationFromHash, required)
+ list (array[Transaction.InBlock], required)
+ error (Error, required, nullable)

## api/v0.2/accounts/{account_id}/transactions/pending [/accounts/{accountIdOrAddress}/transactions/pending{?from,limit,direction}]

+ Parameters
+ accountIdOrAddress (required, string, `2319`) ... Account Id or address in the zkSync network
+ from (required, "latest" | number, `100`) ... From which transaction to show
+ limit (required, number, `2`) ... The limit of transactions to be shown
+ direction (required, "newer" | "older", `older`) ... newer or older than the id of the `from`

### Get pending priority operations [GET]
Get account pending priority operations.

+ Response 200 (application/json)
+ Attributes
+ request (Request, required)
+ status: success (string, required)
+ result (object, required, nullable)
+ pagination (PaginationFromNumber, required)
+ list (array[Transaction.InBlock.L1], required)
+ error (Error, required, nullable)
35 changes: 35 additions & 0 deletions core/tests/apiary/groups/batches.apib
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Group Batches

## api/v0.2/transactions/batches [/transactions/batches]

### Submit batch of transactions [POST]
Submit batch of transactions.

+ Request (application/json)
+ Attributes
+ txs (array[Transaction.Incoming], required)
+ signature (BatchSignature, required)

+ Response 200 (application/json)
+ Attributes
+ request (Request, required)
+ status: success (string, required)
+ result (SubmitBatchResponse, required, nullable)
+ error (Error, required, nullable)


## api/v0.2/transactions/batches/:txBatchHash [/transactions/batches/{txBatchHash}]

+ Parameters
+ txBatchHash (required, string, `0x6d6f7e07c85a770c6cb9f667c6b7d2d6335781f956a3a66503c87a56fd392e80`) ... the hash of the contents of the batch queried

### Get transactions batch status [GET]
Get transactions batch status (latest receipt)

+ Response 200 (application/json)
+ Attributes
+ request (Request, required)
+ status: success (string, required)
+ result (BatchStatus, nullable)
+ error (Error, required, nullable)

55 changes: 55 additions & 0 deletions core/tests/apiary/groups/blocks.apib
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Group Blocks

## api/v0.2/blocks [/blocks{?from,limit,direction}]

+ Parameters
+ from (required, "latest" | number, `latest`) ... From which transaction to show
+ limit (required, number, `2`) ... The limit of transactions to be shown
+ direction (required, "newer" | "older", `older`) ... newer or older than the id of the `from`

### Get blocks range [GET]
Get blocks range

+ Response 200 (application/json)
+ Attributes
+ request (Request, required)
+ status: success (string, required)
+ result (object, required, nullable)
+ pagination (PaginationFromNumber, required)
+ list (array[Block], required)
+ error (Error, required, nullable)

## api/v0.2/blocks/:block_number [/blocks/{blockNumber}]

+ Parameters
+ `blockNumber`: `lastCommitted` (required, BlockNumber) - a number of the block or `lastCommitted` for getting the last committed block or `lastFinalized` for getting the last finalized block

### Get block details [GET]
Get block details

+ Response 200 (application/json)
+ Attributes
+ request (Request, required)
+ status: success (string, required)
+ result (Block, required, nullable)
+ error (Error, required, nullable)

## api/v0.2/blocks/blockNumber/transactions [/blocks/{blockNumber}/transactions{?from,limit,direction}]

+ Parameters
+ `blockNumber`: `lastCommitted` (required, BlockNumber) - a number of the block or `lastCommitted` for getting the last committed block or `lastFinalized` for getting the last finalized block
+ from (required, "latest" | string, `latest`) ... From which transaction to show
+ limit (required, number, `2`) ... The limit of transactions to be shown
+ direction (required, "newer" | "older", `older`) ... newer or older than the id of the `from`

### Get block transactions [GET]
Get block transactions

+ Response 200 (application/json)
+ Attributes
+ request (Request, required)
+ status: success (string, required)
+ result (object, required, nullable)
+ pagination (PaginationFromHash, required)
+ list (array[Transaction.InBlock], required)
+ error (Error, required, nullable)
13 changes: 13 additions & 0 deletions core/tests/apiary/groups/config.apib
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Group Config

## api/v0.2/config [/config]

### Get config of network [GET]
Returns the config of network

+ Response 200 (application/json)
+ Attributes
+ request (Request, required)
+ status: success (string, required)
+ result (Config, required, nullable)
+ error (Error, required, nullable)
37 changes: 37 additions & 0 deletions core/tests/apiary/groups/fee.apib
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Group Fees

## api/v0.2/fee [/fee]

### Get fee for a single transaction [POST]
Request fee for a single transaction.

+ Request (application/json)
+ Attributes
+ txType: Transfer (Fee.Type, required)
+ address: 0xf33A2D61DD09541A8C9897D7236aDcCCC14Cf769 (string, required)
+ tokenLike: ETH (Token.TokenLike, required)

+ Response 200 (application/json)
+ Attributes
+ request (Request, required)
+ status: success (string, required)
+ result (Fee.Single, required, nullable)
+ error (Error, required, nullable)

## api/v0.2/fee/batch [/fee/batch]

### Get fee for a transactions batch [POST]
Request fee for a transactions batch.

+ Request (application/json)
+ Attributes
+ transactions (array[Fee.Type.with.Address])
+ tokenLike: ETH (Token.TokenLike)
+ error (Error, required, nullable)

+ Response 200 (application/json)
+ Attributes
+ request (Request, required)
+ status: success (string, required)
+ result (Fee.Batch, required, nullable)
+ error (Error, required, nullable)
13 changes: 13 additions & 0 deletions core/tests/apiary/groups/network-status.apib
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Group Network status

## api/v0.2/networkStatus [/networkStatus]

### Get network status [GET]
Returns the status of the network

+ Response 200 (application/json)
+ Attributes
+ request (Request, required)
+ status: success (string, required)
+ result (NetworkStatus, required, nullable)
+ error (Error, required, nullable)
51 changes: 51 additions & 0 deletions core/tests/apiary/groups/tokens.apib
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Group Tokens

## api/v0.2/tokens [/tokens{?from,limit,direction}]

+ Parameters
+ from (required, "latest" | number, `latest`) ... From which token id to show
+ limit (required, number, `2`) ... The limit of tokens to be returned
+ direction (required, "newer" | "older", `older`) ... newer or older than the id of the `from`

### Get list of supported tokens [GET]
Returns the tokens that are currently supported by zkSync

+ Response 200 (application/json)
+ Attributes
+ request (Request, required)
+ status: success (string, required)
+ result (object, required, nullable)
+ pagination (PaginationFromNumber, required)
+ list (array[Token.Token], required)
+ error (Error, required, nullable)

## api/v0.2/tokens/tokenIdOrAddress [/tokens/{tokenIdOrAddress}]

+ Parameters
+ tokenIdOrAddress (required, number | string, `12`) ... the id or address of the token in the zkSync network

### Get token info [GET]
Get token into

+ Response 200 (application/json)
+ Attributes
+ request (Request, required)
+ status: success (string, required)
+ result (Token.Token, required, nullable)
+ error (Error, required, nullable)

## api/v0.2/tokens/:tokenIdOrAddress/priceIn/:currency [/tokens/{tokenIdOrAddress}/priceIn/{currency}]

+ Parameters
+ tokenIdOrAddress (required, string, `12`) ... the id or address of the token in the zkSync network
+ currency (required, string, `12`) ... either usd or any of the supported tokens in the zkSync network

### Get token price [GET]
Get token price relative to another token

+ Response 200 (application/json)
+ Attributes
+ request (Request, required)
+ status: success (string, required)
+ result (Token.Price, required, nullable)
+ error (Error, required, nullable)
49 changes: 49 additions & 0 deletions core/tests/apiary/groups/transactions.apib
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Group Transactions

## api/v0.2/transactions [/transactions]

### Submit transaction [POST]
Submit single transaction

+ Request (application/json)
+ Attributes
+ tx (Transaction.Incoming, required)
+ signature (TxEthSignature, optional, nullable)

+ Response 200 (application/json)
+ Attributes
+ request (Request, required)
+ status: success (string, required)
+ result: 0xb092a0a2eabbf0b5b57d18e70d929899676cf3c0ad4df0f9492c3094ec4a8b19 (string, required, nullable)
+ error (Error, required, nullable)

## api/v0.2/transactions/:txHash [/transactions/{txHash}]

+ Parameters
+ txHash (required, string, `0x4727e2c87cf831bbb99f5699d8c574ecad8fcf1371875feb059440f1077fa071`) ... hash of the transaction in the zkSync network

### Get transaction receipt [GET]
Get transaction receipt

+ Response 200 (application/json)
+ Attributes
+ request (Request, required)
+ status: success (string, required)
+ result (Receipt, required, nullable)
+ error (Error, required, nullable)


## api/v0.2/transactions/:txHash/data [/transactions/{txHash}/data]

+ Parameters
+ txHash (required, string, `0x4727e2c87cf831bbb99f5699d8c574ecad8fcf1371875feb059440f1077fa071`) ... hash of the transaction in the zkSync network

### Get transaction data [GET]
Get transaction data

+ Response 200 (application/json)
+ Attributes
+ request (Request, required)
+ status: success (string, required)
+ result (Transaction.InBlock, required, nullable)
+ error (Error, required, nullable)
Loading

0 comments on commit 41ac552

Please sign in to comment.