refactor wip
This commit is contained in:
@ -2,9 +2,10 @@ from flask import Flask, jsonify, request, render_template, redirect, url_for
|
||||
# from flask_oauthlib.client import OAuth
|
||||
from flask_login import LoginManager, UserMixin, login_user, login_required, logout_user, current_user
|
||||
import secrets
|
||||
from modules import storage
|
||||
from modules import storage, utils, SolanaAPI
|
||||
import os
|
||||
|
||||
|
||||
def init_app():
|
||||
app = Flask(__name__, template_folder='../templates', static_folder='../static')
|
||||
app.config['SECRET_KEY'] = 'your-secret-key'
|
||||
@ -117,11 +118,11 @@ def init_app():
|
||||
return jsonify({"error": "No log files found"}), 404
|
||||
|
||||
try:
|
||||
logger.info(f"Processing latest log file: {latest_log_file}")
|
||||
utils.log.info(f"Processing latest log file: {latest_log_file}")
|
||||
with open(latest_log_file, 'r') as f:
|
||||
log = json.load(f)
|
||||
|
||||
result = await process_log(log)
|
||||
result = await SolanaAPI.process_log(log)
|
||||
|
||||
return jsonify({
|
||||
"file": latest_log_file,
|
||||
@ -130,7 +131,7 @@ def init_app():
|
||||
}), 200
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"Error processing log dump: {e}")
|
||||
utils.log.error(f"Error processing log dump: {e}")
|
||||
return jsonify({"error": "Failed to process log"}), 500
|
||||
|
||||
|
||||
@ -141,7 +142,7 @@ def init_app():
|
||||
@app.route('/tr/<wallet>/<tx_signature>', methods=['GET', 'POST'])
|
||||
async def transaction_notified(wallet, tx_signature):
|
||||
try:
|
||||
logger.info(f"Processing transaction notification for wallet: {wallet}, tx: {tx_signature}")
|
||||
utils.log.info(f"Processing transaction notification for wallet: {wallet}, tx: {tx_signature}")
|
||||
# Process the transaction
|
||||
# tr = await get_swap_transaction_details(tx_signature)
|
||||
tr = await get_transaction_details_info(tx_signature, [])
|
||||
@ -152,7 +153,7 @@ def init_app():
|
||||
await save_token_info()
|
||||
return jsonify(tr), 200
|
||||
except Exception as e:
|
||||
logging.error(f"Error processing transaction: {e}")
|
||||
utils.log.error(f"Error processing transaction: {e}")
|
||||
return jsonify({"error": "Failed to process transaction"}), 500
|
||||
|
||||
|
||||
@ -174,5 +175,5 @@ def get_latest_log_file():
|
||||
latest_file = max(files, key=lambda x: os.path.getmtime(os.path.join(log_dir, x)))
|
||||
return os.path.join(log_dir, latest_file)
|
||||
except Exception as e:
|
||||
logging.error(f"Error fetching latest log file: {e}")
|
||||
utils.log.error(f"Error fetching latest log file: {e}")
|
||||
return None
|
||||
|
Reference in New Issue
Block a user