-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathgas.py
More file actions
30 lines (26 loc) · 1.02 KB
/
gas.py
File metadata and controls
30 lines (26 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from fastapi import Depends, Path
from fastapi.routing import APIRouter
from fastapi.security import HTTPBearer
from fastapi_jwt_auth import AuthJWT
from meta_aggregation_api.models.gas_models import GasResponse
from meta_aggregation_api.rest_api import dependencies
gas_routes = APIRouter()
@gas_routes.get(
'/{chain_id}', response_model=GasResponse, dependencies=[Depends(HTTPBearer())]
)
@gas_routes.get(
'/{chain_id}/', include_in_schema=False, dependencies=[Depends(HTTPBearer())]
)
@gas_routes.get('/{chain_id}', response_model=GasResponse)
@gas_routes.get('/{chain_id}/', include_in_schema=False)
async def get_prices(
authorize: AuthJWT = Depends(),
chain_id: int = Path(..., description='Chain ID'),
gas_service: dependencies.GasService = Depends(dependencies.gas_service),
) -> GasResponse:
"""
Returns the gas prices for a given chain.
Returned object has not null eip1559 field for chains that support it.
"""
authorize.jwt_required()
return await gas_service.get_gas_prices(chain_id)