mirror of
https://github.com/pezkuwichain/pezkuwi-mobile-app.git
synced 2026-06-09 19:31:01 +00:00
auto-commit for b2a2e76f-d615-4f17-88c0-a5009a102312
This commit is contained in:
@@ -9,6 +9,7 @@ from pydantic import BaseModel, Field
|
||||
from typing import List, Optional, Dict, Any
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
from substrateinterface import SubstrateInterface
|
||||
|
||||
|
||||
ROOT_DIR = Path(__file__).parent
|
||||
@@ -22,6 +23,20 @@ db = client[os.environ['DB_NAME']]
|
||||
# Polkadot RPC endpoint (Local Development Node)
|
||||
POLKADOT_RPC = "ws://127.0.0.1:9944"
|
||||
|
||||
# Initialize Substrate connection
|
||||
substrate = None
|
||||
|
||||
def get_substrate():
|
||||
global substrate
|
||||
if substrate is None:
|
||||
try:
|
||||
substrate = SubstrateInterface(url=POLKADOT_RPC)
|
||||
logger.info(f"✅ Connected to blockchain: {substrate.chain}, {substrate.name}")
|
||||
except Exception as e:
|
||||
logger.error(f"❌ Failed to connect to blockchain: {e}")
|
||||
substrate = None
|
||||
return substrate
|
||||
|
||||
# Create the main app without a prefix
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user