-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
executable file
·44 lines (31 loc) · 943 Bytes
/
main.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import asyncio
import os
from dotenv import load_dotenv
from prisma import Prisma
import telegram_bot
import blockchain
import db
load_dotenv()
contract_address = os.getenv("CONTRACT_ADDRESS")
infura_url = os.getenv("INFURA_URL")
telegram_api_key = os.getenv("TELEGRAM_API")
def main():
prsm = Prisma()
asyncio.run(prsm.connect())
event_repository = db.EventRepository(prsm)
telegram_bot.main(telegram_api_key, event_repository)
blockchain.main(infura_url, contract_address, event_repository)
asyncio.run(blockchain.get_historic_events())
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
try:
loop.run_until_complete(
asyncio.gather(
telegram_bot.send(),
blockchain.listen_for_events()
)
)
finally:
loop.close()
if __name__ == "__main__":
main()