mirror of
https://github.com/autistic-symposium/blockchain-data-engineering-toolkit.git
synced 2025-04-26 10:49:23 -04:00
ready for production
This commit is contained in:
parent
a58c917f0f
commit
5c4cc3f87d
@ -32,9 +32,6 @@ def run_menu() -> argparse.ArgumentParser:
|
|||||||
parser.add_argument('-a', dest='api', action='store_true',
|
parser.add_argument('-a', dest='api', action='store_true',
|
||||||
help="Run the event scanner api locally. \
|
help="Run the event scanner api locally. \
|
||||||
Example: indexer -a")
|
Example: indexer -a")
|
||||||
parser.add_argument('-c', dest='vercel', action='store_true',
|
|
||||||
help="Deploy event scanner to Vercel. \
|
|
||||||
Example: indexer -c")
|
|
||||||
|
|
||||||
parser.add_argument('-b', dest='balance', nargs=1,
|
parser.add_argument('-b', dest='balance', nargs=1,
|
||||||
help="Fetch token balance for a given wallet. \
|
help="Fetch token balance for a given wallet. \
|
||||||
@ -42,9 +39,7 @@ def run_menu() -> argparse.ArgumentParser:
|
|||||||
parser.add_argument('-t', dest='top', action='store_true',
|
parser.add_argument('-t', dest='top', action='store_true',
|
||||||
help="Fetch top token holders. \
|
help="Fetch top token holders. \
|
||||||
Example: indexer -t <number of holders>")
|
Example: indexer -t <number of holders>")
|
||||||
parser.add_argument('-g', dest='change', nargs=1,
|
|
||||||
help="Fetch weekly balance change for a given wallet. \
|
|
||||||
Example: indexer -g <wallet address>")
|
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
@ -73,8 +68,6 @@ def run() -> None:
|
|||||||
host = env_vars['API_HOST_URL']
|
host = env_vars['API_HOST_URL']
|
||||||
port = int(env_vars['API_HOST_PORT'])
|
port = int(env_vars['API_HOST_PORT'])
|
||||||
uvicorn.run("src.server.api:app", host=host, port=port, reload=True)
|
uvicorn.run("src.server.api:app", host=host, port=port, reload=True)
|
||||||
elif args.vercel:
|
|
||||||
upload_to_vercel()
|
|
||||||
|
|
||||||
#############################
|
#############################
|
||||||
# Run api tests
|
# Run api tests
|
||||||
@ -83,8 +76,7 @@ def run() -> None:
|
|||||||
fetch_token_balance(env_vars, args.balance[0])
|
fetch_token_balance(env_vars, args.balance[0])
|
||||||
elif args.top:
|
elif args.top:
|
||||||
fetch_top_token_holders(env_vars)
|
fetch_top_token_holders(env_vars)
|
||||||
elif args.change:
|
|
||||||
fetch_change(env_vars, args.change[0])
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
|
@ -63,16 +63,3 @@ async def retrieve_balance(wallet: str) -> dict:
|
|||||||
else:
|
else:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
||||||
async def retrieve_holder_weekly_change(address: str) -> int:
|
|
||||||
"""Retrieve weekly change of a given address."""
|
|
||||||
|
|
||||||
collection = _get_db_collection()
|
|
||||||
# todo
|
|
||||||
# get today time
|
|
||||||
# get last week time
|
|
||||||
# find block last week
|
|
||||||
# get balance of address in block last week
|
|
||||||
# get balance of address in block today
|
|
||||||
# calculate difference and percentage
|
|
||||||
pass
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
from fastapi import APIRouter
|
from fastapi import APIRouter
|
||||||
|
|
||||||
from src.server.database import retrieve_balance, retrieve_top_balances, retrieve_holder_weekly_change
|
from src.server.database import retrieve_balance, retrieve_top_balances
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
@ -40,16 +40,3 @@ async def get_top_holders() -> dict:
|
|||||||
return {"result": result[0]}
|
return {"result": result[0]}
|
||||||
else:
|
else:
|
||||||
return {"error": "No holders found"}
|
return {"error": "No holders found"}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@router.get("/weekly/{address}")
|
|
||||||
async def get_holder_weekly_change(address: str) -> dict:
|
|
||||||
"""Get weekly change of a given address."""
|
|
||||||
|
|
||||||
futures = [retrieve_holder_weekly_change(address)]
|
|
||||||
result = await asyncio.gather(*futures)
|
|
||||||
if result:
|
|
||||||
return {"result": result}
|
|
||||||
else:
|
|
||||||
return {"error": "Wallet not found"}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user