installed prisma for py
This commit is contained in:
@ -1,10 +1,11 @@
|
||||
import os
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
from .storage import store_transaction
|
||||
from .storage import store_transaction, prisma_client
|
||||
from .SolanaAPI import SolanaAPI
|
||||
|
||||
LOG_DIRECTORY = "path/to/log/directory"
|
||||
FILE_MASK = "*.log"
|
||||
LOG_DIRECTORY = "logs"
|
||||
FILE_MASK = "wh_*.json"
|
||||
|
||||
async def process_log_file(file_path):
|
||||
# Read the file and extract transaction data
|
||||
@ -22,8 +23,18 @@ async def process_log_file(file_path):
|
||||
solana_signature = "extracted_solana_signature"
|
||||
details = {}
|
||||
|
||||
# Store the transaction
|
||||
await store_transaction(wallet_id, transaction_type, sell_currency, sell_amount, sell_value, buy_currency, buy_amount, buy_value, solana_signature, details)
|
||||
# Process the webhook data
|
||||
solana_api = SolanaAPI()
|
||||
transaction_data = await solana_api.process_wh(data)
|
||||
|
||||
# Check if the transaction already exists
|
||||
existing_transaction = await prisma_client.transaction.find_first(
|
||||
where={'solana_signature': solana_signature}
|
||||
)
|
||||
|
||||
if not existing_transaction:
|
||||
# Store the transaction if it doesn't exist
|
||||
await store_transaction(wallet_id, transaction_type, sell_currency, sell_amount, sell_value, buy_currency, buy_amount, buy_value, solana_signature, details)
|
||||
|
||||
# Rename the file to append '_saved'
|
||||
new_file_path = file_path.with_name(file_path.stem + "_saved" + file_path.suffix)
|
||||
|
Reference in New Issue
Block a user