Feeder Gateway
- class services.starkex.feeder_gateway.feeder_gateway.FeederGateway(feeder_gateway_config: dict, storage: starkware.storage.storage.Storage)
This is the StarkEx Services HTTP gateway for feeder interactions. The Feeder is a gateway to the StarkEx system for retrieving transaction batch information by external parties. Access to information is based on batch IDs only. The intention is to allow more detailed slicing and dicing to be performed on an external DB rather than via this API.
- async get_batch_enclosing_ids(request) aiohttp.web_response.Response
Get first and last transaction IDs for the input batch_id.
- Parameters
batch_id (int) – Batch ID to query.
- Returns
List of first and last batch IDs (json).
- Return type
str
- Example
http
GET /feeder_gateway/get_batch_enclosing_ids?batch_id=5678 HTTP/1.1 Host: localhost:9413 Accept: application/json
curl
curl -i -X GET 'https://localhost:9413/feeder_gateway/get_batch_enclosing_ids?batch_id=5678' -H "Accept: application/json"
wget
wget -S -O- 'https://localhost:9413/feeder_gateway/get_batch_enclosing_ids?batch_id=5678' --header="Accept: application/json"
httpie
http 'https://localhost:9413/feeder_gateway/get_batch_enclosing_ids?batch_id=5678' Accept:application/json
python-requests
requests.get('https://localhost:9413/feeder_gateway/get_batch_enclosing_ids?batch_id=5678', headers={'Accept': 'application/json'})
response
HTTP/1.1 200 OK Content-Type: application/json [10000, 12345]
- async get_batch_ids(request) aiohttp.web_response.Response
Get a list of batch IDs matching the input vaults root, orders root and sequence number.
- Parameters
vault_root (int) – Vaults root to query.
order_root (int) – Orders root to query.
sequence_number (int) – Sequence number to query.
- Returns
List of batch IDs (json).
- Return type
str
- Example
http
GET /feeder_gateway/get_batch_ids?vault_root=0x46bc9d7b7716bc33b1db5b7509c0a076ab9424ba5e16dd26de8097a62f1ef1d1&order_root=0x84695d9d13ec0eeafc07b7d0c5da3f30e42e468bc69413c2b77e62cd8cdeb9a8&sequence_number=5678 HTTP/1.1 Host: localhost:9413 Accept: application/json
curl
curl -i -X GET 'https://localhost:9413/feeder_gateway/get_batch_ids?vault_root=0x46bc9d7b7716bc33b1db5b7509c0a076ab9424ba5e16dd26de8097a62f1ef1d1&order_root=0x84695d9d13ec0eeafc07b7d0c5da3f30e42e468bc69413c2b77e62cd8cdeb9a8&sequence_number=5678' -H "Accept: application/json"
wget
wget -S -O- 'https://localhost:9413/feeder_gateway/get_batch_ids?vault_root=0x46bc9d7b7716bc33b1db5b7509c0a076ab9424ba5e16dd26de8097a62f1ef1d1&order_root=0x84695d9d13ec0eeafc07b7d0c5da3f30e42e468bc69413c2b77e62cd8cdeb9a8&sequence_number=5678' --header="Accept: application/json"
httpie
http 'https://localhost:9413/feeder_gateway/get_batch_ids?vault_root=0x46bc9d7b7716bc33b1db5b7509c0a076ab9424ba5e16dd26de8097a62f1ef1d1&order_root=0x84695d9d13ec0eeafc07b7d0c5da3f30e42e468bc69413c2b77e62cd8cdeb9a8&sequence_number=5678' Accept:application/json
python-requests
requests.get('https://localhost:9413/feeder_gateway/get_batch_ids?vault_root=0x46bc9d7b7716bc33b1db5b7509c0a076ab9424ba5e16dd26de8097a62f1ef1d1&order_root=0x84695d9d13ec0eeafc07b7d0c5da3f30e42e468bc69413c2b77e62cd8cdeb9a8&sequence_number=5678', headers={'Accept': 'application/json'})
response
HTTP/1.1 200 OK Content-Type: application/json [123, 456]
- async get_batch_info(request) aiohttp.web_response.Response
Get detailed batch information. See the response example for returned keys and values.
- Parameters
batch_id (int) – Batch ID to query.
- Returns
Batch information (json).
- Return type
str
- Example
http
GET /feeder_gateway/get_batch_info?batch_id=5678 HTTP/1.1 Host: localhost:9413 Accept: application/json
curl
curl -i -X GET 'https://localhost:9413/feeder_gateway/get_batch_info?batch_id=5678' -H "Accept: application/json"
wget
wget -S -O- 'https://localhost:9413/feeder_gateway/get_batch_info?batch_id=5678' --header="Accept: application/json"
httpie
http 'https://localhost:9413/feeder_gateway/get_batch_info?batch_id=5678' Accept:application/json
python-requests
requests.get('https://localhost:9413/feeder_gateway/get_batch_info?batch_id=5678', headers={'Accept': 'application/json'})
response
HTTP/1.1 200 OK Content-Type: application/json { "order_root": { "height": 31, "root": "04695d9d13ec0eeafc07b7d0c5da3f30e42e468bc69413c2b77e62cd8cdeb9a8" }, "prev_batch_id": 5677, "prev_order_root": { "height": 31, "root": "04695d9d13ec0eeafc07b7d0c5da3f30e42e468bc69413c2b77e62cd8cdeb9a8" }, "prev_vault_root": { "height": 31, "root": "0075364111a7a336756626d19fc8ec8df6328a5e63681c68ffaa312f6bf98c5c" }, "sequence_number": 1234, "time_created": 1614665098, "txs_info": [ { "alt_txs": [], "original_tx": { "amount": "1000", "stark_key": "0x51ddea3f6955ab96cdbb24e2b88c7ce6e7d1afea354e41be88d9dca5c7f0651", "token_id": "0x2dc6cb834b9f656f3366c0c263e75458a814074b165bc1661b7460e7c972759", "type": "DepositRequest", "vault_id": 931081472 }, "tx_id": 123456, "was_replaced": false } ], "vault_root": { "height": 31, "root": "00bc9d7b7716bc33b1db5b7509c0a076ab9424ba5e16dd26de8097a62f1ef1d1" } }
- async get_last_batch_id(request) aiohttp.web_response.Response
Get the last batch ID used by StarkEx.
- Returns
Last batch ID.
- Return type
int
- Example
http
GET /feeder_gateway/get_last_batch_id HTTP/1.1 Host: localhost:9413 Accept: application/json
curl
curl -i -X GET https://localhost:9413/feeder_gateway/get_last_batch_id -H "Accept: application/json"
wget
wget -S -O- https://localhost:9413/feeder_gateway/get_last_batch_id --header="Accept: application/json"
httpie
http https://localhost:9413/feeder_gateway/get_last_batch_id Accept:application/json
python-requests
requests.get('https://localhost:9413/feeder_gateway/get_last_batch_id', headers={'Accept': 'application/json'})
response
HTTP/1.1 200 OK Content-Type: application/json 5678
- async is_batch_created_aborted(batch_id) bool
Checks if batch created was aborted.