Rafata12/FindMy-Wallet
1
1import gradio as gr2import random3 4# بيانات تجريبية (Mock wallets مرتبطة بالإيميل)5dummy_data = {6 "user1@example.com": ["BTC: 0.02", "ETH: 0.5", "USDT: 100"],7 "user2@example.com": ["BNB: 3.1", "DOGE: 2500"],8}9 10# 1️⃣ البحث عن المحافظ11def find_wallets(email):12 results = dummy_data.get(email.lower(), [])13 if results:14 return results, f"✅ Found {len(results)} wallets linked to {email}"15 else:16 return [], f"❌ No wallets found for {email}. Please try another email."17 18# 2️⃣ توليد كود تحقق (OTP) للتأكيد19def confirm_transfer(wallet_choice, email):20 if wallet_choice:21 otp = random.randint(100000, 999999) # كود 6 أرقام22 return f"📩 A confirmation code [{otp}] has been sent to {email} for transferring {wallet_choice}."23 else:24 return "⚠️ Please select a wallet before confirming."25 26# واجهة Gradio27with gr.Blocks(theme=gr.themes.Soft()) as demo:28 gr.Markdown("## 👜 FindMy Wallet\nSearch and transfer your crypto with email confirmation (demo).")29 30 with gr.Row():31 email_input = gr.Textbox(label="Email Address", placeholder="Enter your email...")32 33 search_btn = gr.Button("🔍 Search Wallets")34 status_output = gr.Textbox(label="Status", interactive=False)35 36 wallet_dropdown = gr.Dropdown(label="Available Wallets", choices=[], interactive=True)37 confirm_btn = gr.Button("✅ Confirm Transfer")38 confirm_output = gr.Textbox(label="Confirmation Result", interactive=False)39 40 # ربط الأزرار بالدوال41 search_btn.click(fn=find_wallets, inputs=email_input, outputs=[wallet_dropdown, status_output])42 confirm_btn.click(fn=confirm_transfer, inputs=[wallet_dropdown, email_input], outputs=confirm_output)43 44# تشغيل التطبيق (بدون share=True ولا ssr_mode)45if __name__ == "__main__":46 demo.launch()47 