metadata-alpha.json, elaborate_metadata.py
This commit is contained in:
20
logging-alpha.toml
Normal file
20
logging-alpha.toml
Normal file
@@ -0,0 +1,20 @@
|
||||
# https://docs.python.org/3/library/logging.config.html#logging-config-dictschema
|
||||
version=1
|
||||
|
||||
[loggers.'']
|
||||
level='INFO'
|
||||
handlers=['console',]
|
||||
|
||||
[loggers.dexorder]
|
||||
level='DEBUG'
|
||||
|
||||
[handlers.console]
|
||||
class='logging.StreamHandler'
|
||||
formatter='notime'
|
||||
stream='ext://sys.stdout'
|
||||
|
||||
[formatters.notime]
|
||||
# https://docs.python.org/3/library/logging.html#logrecord-attributes
|
||||
format='%(levelname)s %(name)s %(message)s'
|
||||
# https://docs.python.org/3/library/time.html#time.strftime
|
||||
datefmt='%Y-%m-%d %H:%M:%S'
|
||||
1
metadata-alpha.json
Normal file
1
metadata-alpha.json
Normal file
File diff suppressed because one or more lines are too long
41
src/dexorder/bin/elaborate_metadata.py
Normal file
41
src/dexorder/bin/elaborate_metadata.py
Normal file
@@ -0,0 +1,41 @@
|
||||
# Reads the configured metadata.json file and fills in any missing fields using blockchain data. Prints
|
||||
# the completed metadata.json file to stdout
|
||||
#
|
||||
# see metadata.py
|
||||
import asyncio
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from dexorder import config, blockchain
|
||||
from dexorder.blockstate import current_blockstate
|
||||
from dexorder.blockstate.state import FinalizedBlockState
|
||||
from dexorder.configuration import parse_args
|
||||
from dexorder.metadata import generate_metadata, get_metadata
|
||||
from dexorder.pools import get_pool
|
||||
from dexorder.tokens import get_token
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
async def main():
|
||||
logging.basicConfig(level=logging.INFO, stream=sys.stderr)
|
||||
logging.getLogger('dexorder').setLevel(logging.DEBUG)
|
||||
parse_args()
|
||||
current_blockstate.set(FinalizedBlockState())
|
||||
await blockchain.connect()
|
||||
if not config.metadata:
|
||||
log.error("Must configure a metadata file")
|
||||
exit(1)
|
||||
tokens = []
|
||||
pools = []
|
||||
for chain_id_str, chain_data in get_metadata().items():
|
||||
for token in chain_data.get('t',[]):
|
||||
log.debug(f'elaborating token {token}')
|
||||
tokens.append(await get_token(token['a']))
|
||||
for pool in chain_data.get('p',[]):
|
||||
log.debug(f'elaborating pool {pool}')
|
||||
pools.append(await get_pool(pool['a']))
|
||||
generate_metadata(tokens, pools)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.run(main())
|
||||
@@ -93,8 +93,11 @@ class BlockStateRunner(BlockProgressor):
|
||||
await async_yield()
|
||||
except (ConnectionClosedError, TimeoutError, asyncio.TimeoutError) as e:
|
||||
log.debug(f'runner timeout {e}')
|
||||
except ConnectionRefusedError:
|
||||
log.warning(f'Could not connect to websocket {config.ws_url}')
|
||||
await asyncio.sleep(1)
|
||||
except Exception:
|
||||
log.exception(f'Unhandled exception during run_polling()')
|
||||
log.exception(f'Unhandled exception during run_ws()')
|
||||
finally:
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
|
||||
@@ -14,6 +14,7 @@ from dexorder.metadata import get_metadata
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# todo needs chain_id
|
||||
async def get_token(address) -> Optional[TokenDict]:
|
||||
if address == ADDRESS_0:
|
||||
raise ValueError('No token at address 0')
|
||||
|
||||
Reference in New Issue
Block a user